本文整理汇总了Python中coapthon.messages.message.Message.token方法的典型用法代码示例。如果您正苦于以下问题:Python Message.token方法的具体用法?Python Message.token怎么用?Python Message.token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coapthon.messages.message.Message
的用法示例。
在下文中一共展示了Message.token方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_with_client_observe
# 需要导入模块: from coapthon.messages.message import Message [as 别名]
# 或者: from coapthon.messages.message.Message import token [as 别名]
def _test_with_client_observe(self, message_list, callback):
client = HelperClient(self.server_address)
token = None
last_mid = 0
for message, expected in message_list:
if message is not None:
token = message.token
client.send_request(message, callback)
received_message = self.queue.get()
if expected is not None:
last_mid = expected.mid
if expected.type is not None:
self.assertEqual(received_message.type, expected.type)
if expected.mid is not None:
self.assertEqual(received_message.mid, expected.mid)
self.assertEqual(received_message.code, expected.code)
if expected.source is not None:
self.assertEqual(received_message.source, self.server_address)
if expected.token is not None:
self.assertEqual(received_message.token, expected.token)
if expected.payload is not None:
self.assertEqual(received_message.payload, expected.payload)
if expected.options is not None:
self.assertEqual(received_message.options, expected.options)
message = Message()
message.type = defines.Types["RST"]
message.token = token
message._mid = last_mid
message.destination = self.server_address
client.send_empty(message)
client.stop()
示例2: cancel_observing
# 需要导入模块: from coapthon.messages.message import Message [as 别名]
# 或者: from coapthon.messages.message.Message import token [as 别名]
def cancel_observing(self, response, send_rst): # pragma: no cover
if send_rst:
message = Message()
message.destination = self.server
message.code = defines.Codes.EMPTY.number
message.type = defines.Types["RST"]
message.token = response.token
message.mid = response.mid
self.protocol.send_message(message)
self.stop()
示例3: end_observation
# 需要导入模块: from coapthon.messages.message import Message [as 别名]
# 或者: from coapthon.messages.message.Message import token [as 别名]
def end_observation(self, token):
"""
Remove an observation token from our records.
:param token: the token for the observation
"""
dummy = Message()
dummy.token = token
dummy.destination = self._server
self._observeLayer.remove_subscriber(dummy)
示例4: coap_encode
# 需要导入模块: from coapthon.messages.message import Message [as 别名]
# 或者: from coapthon.messages.message.Message import token [as 别名]
def coap_encode(payload):
message = Message()
message.type = defines.Types['CON']
message.token = 4321
message.mid = 2
message.options = None
message.payload = str(payload)
serializer = Serializer()
messagestring = serializer.serialize(message)
return messagestring