pyrtc.transport

class pyrtc.transport.EventReceiver

A helper class to allow multiple targets receive events from Websocket

property pending

True if there are events in the buffer, False otherwise

Type

bool

post(evt)

Add an event to the buffer.

class pyrtc.transport.Websocket(cli_sock)

A class that wraps a socket and transmits data over it through the WebSocket protocol defined in RFC 6455.

add_receiver(receiver)

Adds a target for received events.

Parameters

receiver (EventReceiver) – The event target.

close(status=1000)

Closes the WebSocket connection with the specified status (1000, the all-ok status code for WebSocket closure)

Parameters

status (int) – The status code to close with.

close_raw()

A safe close function that will cleanly close the socket if the WebSocket connection state is not open.

property open

Whether the connection is open.

Type

bool

receive()

Receives all available data from socket, then posts all all events to all added receivers.

send(data)

Send data over the WebSocket connection. May be a str or bytes, but the ws.proto Message counterparts are accepted as well.