platypush.plugins.websocket

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

Plugin to send messages over a websocket connection

Requires:

  • websockets (pip install websockets)
__init__(*args, **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, *args, **kwargs)[source]

Sends a message to a websocket.

Parameters:
  • url – 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 (str) – Path to the SSL certificate to be used, if the SSL connection requires client authentication as well (default: None)
  • ssl_key (str) – Path to the SSL key to be used, if the SSL connection requires client authentication as well (default: None)
  • 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)