本文整理汇总了Python中autobahn.websocket.WebSocketServerProtocol.sendMessage方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketServerProtocol.sendMessage方法的具体用法?Python WebSocketServerProtocol.sendMessage怎么用?Python WebSocketServerProtocol.sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.websocket.WebSocketServerProtocol
的用法示例。
在下文中一共展示了WebSocketServerProtocol.sendMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendMessage
# 需要导入模块: from autobahn.websocket import WebSocketServerProtocol [as 别名]
# 或者: from autobahn.websocket.WebSocketServerProtocol import sendMessage [as 别名]
def sendMessage(self, payload, binary=False):
if isinstance(payload, dict) and not binary:
msg = json.dumps(payload)
else:
msg = json.dumps({'message': payload})
WebSocketServerProtocol.sendMessage(self, msg, binary=binary)
示例2: sendMessage
# 需要导入模块: from autobahn.websocket import WebSocketServerProtocol [as 别名]
# 或者: from autobahn.websocket.WebSocketServerProtocol import sendMessage [as 别名]
def sendMessage(self, msg):
""" This method is called by the User instance to send a message to the
robot.
@param msg: Message which should be sent
"""
uriBinary, msgURI = recursiveBinarySearch(msg)
WebSocketServerProtocol.sendMessage(self, json.dumps(msgURI))
for binData in uriBinary:
WebSocketServerProtocol.sendMessage(self,
binData[0] + binData[1].getvalue(), binary=True)
示例3: sendMessage
# 需要导入模块: from autobahn.websocket import WebSocketServerProtocol [as 别名]
# 或者: from autobahn.websocket.WebSocketServerProtocol import sendMessage [as 别名]
def sendMessage(self, msg):
""" Internally used method to send a message to the robot.
Should not be used from outside the Protocol; instead use the
methods 'sendDataMessage' or 'sendErrorMessage'.
(Overwrites method from autobahn.websocket.WebSocketServerProtocol)
@param msg: Message which should be sent.
"""
uriBinary, msgURI = recursiveBinarySearch(msg)
WebSocketServerProtocol.sendMessage(self, json.dumps(msgURI))
for binData in uriBinary:
WebSocketServerProtocol.sendMessage(self,
binData[0] + binData[1].getvalue(), binary=True)
示例4: sendMessage
# 需要导入模块: from autobahn.websocket import WebSocketServerProtocol [as 别名]
# 或者: from autobahn.websocket.WebSocketServerProtocol import sendMessage [as 别名]
def sendMessage(self, msg, binary = False):
WebSocketServerProtocol.sendMessage(self, msg, binary)
示例5: sendMessage
# 需要导入模块: from autobahn.websocket import WebSocketServerProtocol [as 别名]
# 或者: from autobahn.websocket.WebSocketServerProtocol import sendMessage [as 别名]
def sendMessage(self, payload, binary=False, payload_frag_size=None, sync=False):
self._my_status = SOCKET_STATUS_WAITING # 等待状态
WebSocketServerProtocol.sendMessage(self, payload, binary, payload_frag_size, sync)