pyrtc.transceiver
- class pyrtc.transceiver.Transceiver
Abstract base class for all transceivers.
- abstract close()
Close the connection used for sending and receiving data.
- abstract is_open()
A method used to check whether the channel used to transmit and received data is open.
- abstract receive()
A generator yielding all relevant events at the time it is called.
Events should be yielded as a 2-tuple (event_type, event_data)
- abstract send(event_type, event_data)
A method which sends an event to an endpoint. How the data is sent or formatted is defined by individual subclasses and is not important as long as it sent somehow.
- Parameters
event_type (str) – The type of event to be processed.
event_data (dict) – Data describing the event.
- class pyrtc.transceiver.TransceiverManager(is_async=False)
A helper class used by
Pool
to aggregate events from transceivers and easily close down all connections at once.- close_all()
Close all transcievers.
- dispatch(transceiver)
Adds a transceiver to this manager instance.
- events()
Used by PoolManager to receive all events from all transceivers and handle them.
- class pyrtc.transceiver.WebsocketTransceiver(ws)
- close()
Close the connection to the Websocket.
- is_open()
- Returns
True if the Websocket is open, False otherwise
- Return type
bool
- static of(raw_sock)
Create a WebSocket transceiver from a raw socket. This could be a plain socket or one wrapped in an SSL context.
- Parameters
raw_sock – The socket to create a WebsocketTransceiver around.
- Returns
A WebsocketTransceiver that sends data over a Websocket connection through raw_sock.
- receive()
Receives data from Websocket, and yields events as 2-tuples (as described by
Transceiver
)
- send(event_type, event_data)
Sends an event via the Websocket.
- Parameters
event_type (str) – The type of event to be processed.
event_data (dict) – Data describing the event.
- property socket
The Websocket instance used by this instance to send and receive data.