本文整理汇总了Python中mycroft.messagebus.client.ws.WebsocketClient.build_url方法的典型用法代码示例。如果您正苦于以下问题:Python WebsocketClient.build_url方法的具体用法?Python WebsocketClient.build_url怎么用?Python WebsocketClient.build_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.messagebus.client.ws.WebsocketClient
的用法示例。
在下文中一共展示了WebsocketClient.build_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: from mycroft.messagebus.client.ws import WebsocketClient [as 别名]
# 或者: from mycroft.messagebus.client.ws.WebsocketClient import build_url [as 别名]
def send(messageToSend, dataToSend=None):
"""
Send a single message over the websocket.
Args:
messageToSend (str): Message to send
dataToSend (dict): data structure to go along with the
message, defaults to empty dict.
"""
dataToSend = dataToSend or {}
# Calculate the standard Mycroft messagebus websocket address
config = ConfigurationManager.get().get("websocket")
url = WebsocketClient.build_url(config.get("host"),
config.get("port"),
config.get("route"),
config.get("ssl"))
# Send the provided message/data
ws = create_connection(url)
packet = Message(messageToSend, dataToSend).serialize()
ws.send(packet)
ws.close()