Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
components
libmqtt
Commits
4fea37cd
Commit
4fea37cd
authored
Mar 02, 2018
by
Bilbo Brovall
💬
Browse files
Added some rows to the readme
parent
70616819
Pipeline
#14429
passed with stages
in 34 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
4fea37cd
...
...
@@ -27,6 +27,15 @@ mkdir transport
```
create file transport/mqtt_router.py
```
python
"""
The dispatch function passes the following kwargs
endpoint
client
user_data
message
context: is the named parameters in the path
?payload_data: is message parsed as json
"""
from
libmqtt.router
import
hook_route
@
hook_route
((
'import/data'
,))
# hooks to given topic/topics
...
...
@@ -35,6 +44,14 @@ def import_data(*args, **kwargs): # pylint: disable=unused-argument
csv
=
kwargs
.
get
(
'message'
).
payload
.
decode
(
"utf-8"
)
ImportCsv
(
data
=
csv
)
kwargs
[
'client'
].
publish
(
'hello/world'
,
'message can be string or json'
)
# sending {"gender": "man"} to hello/bilbo results in
@
hook_route
((
'hello/(?P<name>+)'
,))
# hooks to given hello/#
def
import_data
(
*
args
,
**
kwargs
):
# pylint: disable=unused-argument
"""sending {"gender": "man} to hello/bilbo results in"""
context
=
kwargs
.
get
(
'context'
,
{})
# is {"name": "bilbo"}
data
=
kwargs
.
get
(
'payload_data'
,
{})
# is {"gender": "man"}
```
### Send messages
...
...
@@ -56,4 +73,4 @@ def import_data(*args, **kwargs): # pylint: disable=unused-argument
### Testing
*
[
flake8
](
http://flake8.pycqa.org/en/latest/
)
*
[
pylint
](
https://docs.pylint.org
)
*
[
setuptools-lint
](
https://pypi.python.org/pypi/setuptools-lint
)
\ No newline at end of file
*
[
setuptools-lint
](
https://pypi.python.org/pypi/setuptools-lint
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment