class documentation
class WebSocketProtocol(typing.Protocol): (source)
An object that conforms to WebSocketProtocol
can receive all the events from a websocket connection.
Note | |
While this is sort of like a byte-stream protocol , the interface is distinct in a few ways; in particular, we have discrete negotiationStarted and negotiationFinished methods, representing those events in the websocket handshaking process, and no connectionMade; similarly, since websockets can natively support both text and bytes messages, rather than fragmentable segments of a byte stream, we have textMessageReceived and bytesMessageReceived but no dataReceived. Finally, this is a typing.Protocol and not a zope.interface.Interface , since it does not predate the typing module. |
Method | bytes |
A bytes message was received from the peer. |
Method | connection |
The websocket connection was lost. |
Method | negotiation |
Negotiation is complete: a bidirectional websocket channel is now fully established. |
Method | negotiation |
An underlying transport (e.g.: a TCP connection) has been established; negotiation of the websocket transport has begun. |
Method | pong |
A Pong message was received. |
Method | text |
A text message was received from the peer. |
An underlying transport (e.g.: a TCP connection) has been established; negotiation of the websocket transport has begun.
A Pong message was received.
Note | |
Per the standard: A Pong frame sent in response to a Ping frame must have identical "Application data" as found in the message body of the Ping frame being replied to. If an endpoint receives a Ping frame and has not yet sent Pong frame(s) in response to previous Ping frame(s), the endpoint MAY elect to send a Pong frame for only the most recently processed Ping frame. Given that some Pong frames may be dropped, this event should only be used in concert with the transport's |