socketio.transports

This is largely an internal module, responsible for translating the different fallback mechanisms to one abstracted Socket, dealing with payload encoding, multi-message multiplexing and their reverse operation.

class socketio.transports.BaseTransport(handler, config, **kwargs)[source]

Bases: object

Base class for all transports. Mostly wraps handler class functions.

start_response(status, headers, **kwargs)[source]
write(data='')[source]
class socketio.transports.FlashSocketTransport(handler, config, **kwargs)[source]

Bases: socketio.transports.WebsocketTransport

class socketio.transports.HTMLFileTransport(handler, config)[source]

Bases: socketio.transports.XHRPollingTransport

Not tested at all!

do_exchange(socket, request_method)[source]
get(socket)[source]
write(data)[source]
write_packed(data)[source]
class socketio.transports.JSONPolling(handler, config)[source]

Bases: socketio.transports.XHRPollingTransport

write(data)[source]

Just quote out stuff before sending it out

class socketio.transports.WebsocketTransport(handler, config, **kwargs)[source]

Bases: socketio.transports.BaseTransport

do_exchange(socket, request_method)[source]
class socketio.transports.XHRMultipartTransport(handler)[source]

Bases: socketio.transports.XHRPollingTransport

do_exchange(socket, request_method)[source]
get(socket)[source]
class socketio.transports.XHRPollingTransport(*args, **kwargs)[source]

Bases: socketio.transports.BaseTransport

decode_payload(payload)[source]

This function can extract multiple messages from one HTTP payload. Some times, the XHR/JSONP/.. transports can pack more than one message on a single packet. They are encoding following the WebSocket semantics, which need to be reproduced here to unwrap the messages.

The semantics are:

ufffd + [length as a string] + ufffd + [payload as a unicode string]

This function returns a list of messages, even though there is only one.

Inspired by socket.io/lib/transports/http.js

do_exchange(socket, request_method)[source]
encode_payload(messages)[source]

Encode list of messages. Expects messages to be unicode.

messages - List of raw messages to encode, if necessary

get(socket)[source]
get_messages_payload(socket, timeout=None)[source]

This will fetch the messages from the Socket’s queue, and if there are many messes, pack multiple messages in one payload and return

options()[source]
post(socket)[source]