Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Eclipse Foundation
paho.mqtt.python
提交
dc85ee56
P
paho.mqtt.python
项目概览
镜像
/
Eclipse Foundation
/
paho.mqtt.python
11 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
paho.mqtt.python
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc85ee56
编写于
4月 20, 2016
作者:
A
Alexis BRENON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix/update comments for calbacks
Signed-off-by:
N
Alexis BRENON
<
brenon.alexis@gmail.com
>
上级
4af8776b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
55 deletion
+90
-55
src/paho/mqtt/client.py
src/paho/mqtt/client.py
+90
-55
未找到文件。
src/paho/mqtt/client.py
浏览文件 @
dc85ee56
...
...
@@ -1323,27 +1323,41 @@ class Client(object):
@
property
def
on_log
(
self
):
"""Called when the client has log information if implemented.
Define to allow debugging.
level: gives the severity of the message and will be one of
MQTT_LOG_INFO, MQTT_LOG_NOTICE, MQTT_LOG_WARNING, MQTT_LOG_ERR, and
MQTT_LOG_DEBUG.
buf: the message itself
"""
"""If implemented, called when the client has log information.
Defined to allow debugging."""
return
self
.
_on_log
@
on_log
.
setter
def
on_log
(
self
,
func
):
""" Define the logging callback implementation.
Expected signature is:
log_callback(client, userdata, level, buf)
client: the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
level: gives the severity of the message and will be one of
MQTT_LOG_INFO, MQTT_LOG_NOTICE, MQTT_LOG_WARNING,
MQTT_LOG_ERR, and MQTT_LOG_DEBUG.
buf: the message itself
"""
self
.
_on_log
=
func
@
property
def
on_connect
(
self
):
"""Called when the broker responds to our connection request if implemented.
"""If implemented, called when the broker responds to our connection
request."""
return
self
.
_on_connect
@
on_connect
.
setter
def
on_connect
(
self
,
func
):
""" Define the connect callback implementation.
self: the client instance for this callback
userdata: the private user data as set in ``Client()`` or ``userdata_set()``
Expected signature is:
connect_callback(client, userdata, flags, rc)
client: the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
flags: response flags sent by the broker
rc: the connection result
...
...
@@ -1363,100 +1377,121 @@ class Client(object):
5: Connection refused - not authorised
6-255: Currently unused.
"""
return
self
.
_on_connect
@
on_connect
.
setter
def
on_connect
(
self
,
func
):
self
.
_on_connect
=
func
@
property
def
on_subscribe
(
self
):
"""Called when the broker responds to a subscribe request if implemented.
"""If implemented, called when the broker responds to a subscribe
request."""
return
self
.
_on_subscribe
@
on_subscribe
.
setter
def
on_subscribe
(
self
,
func
):
""" Define the suscribe callback implementation.
Expected signature is:
subscribe_callback(client, userdata, mid, granted_qos)
client: the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
mid: matches the mid variable returned from the corresponding
subscribe() call.
granted_qos: list of integers that give the QoS level the broker has
granted for each of the different subscription requests.
"""
return
self
.
_on_subscribe
@
on_subscribe
.
setter
def
on_subscribe
(
self
,
func
):
self
.
_on_subscribe
=
func
@
property
def
on_message
(
self
):
"""
Called when a message has been received on a topic that the client
subscribes to if implemented
.
"""
If implemented, called when a message has been received on a topic
that the client subscribes to
.
This callback will be called for every message received. Use
``message_callback_add()`` to define multiple callbacks that will be called for
specific topic filters.
message_callback_add() to define multiple callbacks that will be called
for specific topic filters."""
return
self
.
_on_message
@
on_message
.
setter
def
on_message
(
self
,
func
):
""" Define the message received callback implementation.
self: the client instance for this callback
Expected signature is:
on_message_callback(client, userdata, message)
client: the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
message: an instance of MQTTMessage.
This is a class with members topic, payload, qos, retain.
"""
return
self
.
_on_message
@
on_message
.
setter
def
on_message
(
self
,
func
):
self
.
_on_message
=
func
@
property
def
on_publish
(
self
):
"""Called when a message that was to be sent using the publish() call
has completed transmission to the broker.
This function may be overridden by sub-classes.
"""If implemented, called when a message that was to be sent using the
publish() call has completed transmission to the broker.
For messages with QoS levels 1 and 2, this means that the appropriate
handshakes have completed. For QoS 0, this simply means that the message
has left the client.
This callback is important because even if the publish() call returns
success, it does not always mean that the message has been sent.
mid: matches the mid variable returned from the corresponding
publish() call, to allow outgoing messages to be tracked.
"""
success, it does not always mean that the message has been sent."""
return
self
.
_on_publish
@
on_publish
.
setter
def
on_publish
(
self
,
func
):
""" Define the published message callback implementation.
Expected signature is:
on_publish_callback(client, userdata, mid)
client: the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
mid: matches the mid variable returned from the corresponding
publish() call, to allow outgoing messages to be tracked.
"""
self
.
_on_publish
=
func
@
property
def
on_unsubscribe
(
self
):
"""Called when the broker responds to an unsubscribe request.
This function may be overridden by sub-classes.
mid: matches the mid variable returned from the corresponding
unsubscribe() call.
"""
"""If implemented, called when the broker responds to an unsubscribe
request."""
return
self
.
_on_unsubscribe
@
on_unsubscribe
.
setter
def
on_unsubscribe
(
self
,
func
):
self
.
_on_unsubscribe
=
func
""" Define the unsubscribe callback implementation.
@
property
def
on_disconnect
(
self
):
"""Called when the client disconnects from the broker.
This function may be overridden by sub-classes.
Expected signature is:
unsubscribe_callback(client, userdata, mid)
self:
the client instance for this callback
client:
the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
rc: the disconnection result
mid: matches the mid variable returned from the corresponding
unsubscribe() call.
"""
self
.
_on_unsubscribe
=
func
The rc parameter indicates the disconnection state. If MQTT_ERR_SUCCESS
(0), the callback was called in response to a disconnect() call. If any
other value the disconnection was unexpected, such as might be caused by
a network error.
@
property
def
on_disconnect
(
self
):
"""If implemented, called when the client disconnects from the broker.
"""
return
self
.
_on_disconnect
@
on_disconnect
.
setter
def
on_disconnect
(
self
,
func
):
""" Define the disconnect callback implementation.
Expected signature is:
disconnect_callback(client, userdata, self)
client: the client instance for this callback
userdata: the private user data as set in Client() or userdata_set()
rc: the disconnection result
The rc parameter indicates the disconnection state. If
MQTT_ERR_SUCCESS (0), the callback was called in response to
a disconnect() call. If any other value the disconnection
was unexpected, such as might be caused by a network error.
"""
self
.
_on_disconnect
=
func
def
message_callback_add
(
self
,
sub
,
callback
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录