tornadio2.proto

tornadio2.proto

Socket.IO protocol related functions

Packets

tornadio2.proto.disconnect(endpoint=None)[source]

Generate disconnect packet.

endpoint
Optional endpoint name
tornadio2.proto.connect(endpoint=None)[source]

Generate connect packet.

endpoint
Optional endpoint name
tornadio2.proto.heartbeat()[source]

Generate heartbeat message.

tornadio2.proto.message(endpoint, msg, message_id=None, force_json=False)[source]

Generate message packet.

endpoint
Optional endpoint name
msg
Message to encode. If message is ascii/unicode string, will send message packet. If object or dictionary, will json encode and send as is.
message_id
Optional message id for ACK
force json
Disregard msg type and send the message with JSON type. Usefull for already JSON encoded strings.
tornadio2.proto.event(endpoint, name, message_id, *args, **kwargs)[source]

Generate event message.

endpoint
Optional endpoint name
name
Event name
message_id
Optional message id for ACK
args
Optional event arguments.
kwargs
Optional event arguments. Will be encoded as dictionary.
tornadio2.proto.ack(endpoint, message_id, ack_response=None)[source]

Generate ACK packet.

endpoint
Optional endpoint name
message_id
Message id to acknowledge
ack_response
Acknowledgment response data (will be json serialized)
tornadio2.proto.error(endpoint, reason, advice=None)[source]

Generate error packet.

endpoint
Optional endpoint name
reason
Error reason
advice
Error advice
tornadio2.proto.noop()[source]

Generate noop packet.

JSON

tornadio2.proto.json_dumps(msg)[source]

Dump object as a json string

msg
Object to dump
tornadio2.proto.json_load(msg)[source]

Load json-encoded object

msg
json encoded object

Frames

tornadio2.proto.decode_frames(data)[source]

Decode socket.io encoded messages. Returns list of packets.

data
encoded messages
tornadio2.proto.encode_frames(packets)[source]

Encode list of packets.

packets
List of packets to encode