slidge.plugins.mattermost.websocket
#
Module Contents#
Classes#
str(object='') -> str |
|
Functions#
|
Attributes#
- class slidge.plugins.mattermost.websocket.EventType[source]#
-
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
Initialize self. See help(type(self)) for accurate signature.
- class slidge.plugins.mattermost.websocket.Websocket(url, token)[source]#
- async connect(event_handler)[source]#
Connect to the websocket and authenticate it. When the authentication has finished, start the loop listening for messages, sending a ping to the server to keep the connection alive. :param event_handler: Every websocket event will be passed there. Takes one argument. :type event_handler: Function(message) :return:
- async _start_loop(websocket, event_handler)[source]#
We will listen for websockets events, sending a heartbeats on a timer. If we don’t the webserver would close the idle connection, forcing us to reconnect.
- async _do_heartbeats(websocket)[source]#
This is a little complicated, but we only need to pong the websocket if we haven’t received a message inside the timeout window. Since messages can be received, while we are waiting we need to check after sleep.