Events¶
-
class
lomond.events.BackOff(delay)¶ Generated when a persistent connection has to wait before re- attempting a connection.
Parameters: delay (float) – The delay (in seconds) before Lomond will re- attempt to connect.
-
class
lomond.events.Binary(data)¶ Generated when Lomond receives a binary message from the server.
Parameters: data (bytes) – The binary payload.
-
class
lomond.events.Closed(code, reason)¶ Generated when the websocket was closed. The websocket may no longer send packets after this event has been received. This event will be followed by
Disconnected.Parameters: - code – The closed code returned from the server.
- reason (str) – An optional description why the websocket was closed, as returned from the server.
-
class
lomond.events.Closing(code, reason)¶ Generated when the server is closing the connection.
No more messages will be received from the server, but you may still send messages while handling this event. A
Disconnectedevent should be generated shortly after this event.Parameters: - code – The closed code returned from the server.
- reason (str) – An optional description why the websocket was closed, as returned from the server.
-
class
lomond.events.ConnectFail(reason)¶ Generate when Lomond was unable to connect to a Websocket server.
Parameters: reason (str) – A short description of the reason for the failure.
-
class
lomond.events.Connected(url, proxy=None)¶ Generated when Lomond has connected to a server but not yet negotiated the websocket upgrade.
Parameters: - url (str) – The websocket URL connected to.
- proxy (str) – The proxy URL connected to (or None).
-
class
lomond.events.Connecting(url)¶ Generated prior to establishing a websocket connection to a server.
Parameters: url – The websocket URL the websocket is connecting to.
-
class
lomond.events.Disconnected(reason=u'closed', graceful=False)¶ Generated when a websocket connection has been dropped.
Parameters: - reason (str) – A description of why the websocket was closed.
- graceful (bool) – Flag indicating if the connection was dropped gracefully (True), or disconnected due to a socket failure (False) or other problem.
-
class
lomond.events.Event¶ Base class for a websocket ‘event’.
-
class
lomond.events.Ping(data)¶ Generated when Lomond received a ping packet from the server.
Parameters: data (bytes) – Ping payload data.
-
class
lomond.events.Poll¶ A generated poll event.
-
class
lomond.events.Pong(data)¶ Generated when Lomond receives a pong packet from the server.
Parameters: data (bytes) – The pong payload data.
-
class
lomond.events.ProtocolError(error, critical)¶ Generated when the server deviates from the protocol.
Parameters: - error (str) – A description of the error.
- critical (bool) – Indicates if the error is considered
‘critical’. If
True, Lomond will disconnect immediately. IfFalse, Lomond will send a close message to the server.
-
class
lomond.events.Ready(response, protocol, extensions)¶ Generated when Lomond has connected to the server, and successfully negotiated the websocket upgrade.
Parameters: - response – A
Responseobject. - protocol (str) – A websocket protocol or
Noneif no protocol was supplied. - extensions (set) – A set of negotiated websocket extensions.
Currently only the
'permessage-deflate'extension is supported.
- response – A
-
class
lomond.events.Rejected(response, reason)¶ Server rejected WS connection.
-
class
lomond.events.Text(text)¶ Generated when Lomond receives a text message from the server.
Parameters: text (str) – The text payload. -
json¶ Text decoded as JSON.
Calls
json.loadsto decode thetextattribute, and may throw the same exceptions if the text is not valid json.
-
-
class
lomond.events.UnknownMessage(message)¶ An application message was received, with an unknown opcode.
-
class
lomond.events.Unresponsive¶ The server has not responding to pings within ping_timeout seconds.
Will be followed by a
Disconnectedevent.