platypush.plugins.websocket

class platypush.plugins.websocket.WebsocketPlugin(**kwargs)[source]

Plugin to send messages over a websocket connection

Requires:

  • websockets (pip install websockets)

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

send(url, msg, ssl_cert=None, ssl_key=None, ssl_cafile=None, ssl_capath=None)[source]

Sends a message to a websocket.

Parameters
  • url (str) – Websocket URL, e.g. ws://localhost:8765 or wss://localhost:8765

  • msg – Message to be sent. It can be a list, a dict, or a Message object

  • ssl_cert – Path to the SSL certificate to be used, if the SSL connection requires client authentication as well (default: None) :type ssl_cert: str

  • ssl_key – Path to the SSL key to be used, if the SSL connection requires client authentication as well (default: None) :type ssl_key: str

  • ssl_cafile (str) – Path to the certificate authority file if required by the SSL configuration (default: None)

  • ssl_capath (str) – Path to the certificate authority directory if required by the SSL configuration (default: None)