Skip to content

octoprint.vendor.sockjs.tornado.session#

BaseSession(conn, server) #

Bases: object

Base session implementation class

Base constructor.

conn Connection class server SockJSRouter instance

is_closed property #

Check if session was closed.

broadcast(clients, msg) #

Optimized broadcast implementation. Depending on type of the session, will json-encode message once and will call either send_message or send_jsonifed.

clients Clients iterable msg Message to send

close(code = 3000, message = 'Go away!') #

Close session or endpoint connection.

code Closing code message Close message

delayed_close() #

Delayed close - won't close immediately, but on next ioloop tick.

get_close_reason() #

Return last close reason tuple.

For example

if self.session.is_closed: code, reason = self.session.get_close_reason()

remove_handler(handler) #

Remove active handler from the session

handler Handler to remove

send_jsonified(msg, stats = True) #

Send or queue outgoing message which was json-encoded before. Used by the broadcast method.

msg JSON-encoded message to send stats If set to True, will update statistics after operation completes

send_message(msg, stats = True, binary = False) #

Send or queue outgoing message

msg Message to send stats If set to True, will update statistics after operation completes

set_handler(handler) #

Set transport handler handler Handler, should derive from the sockjs.tornado.transports.base.BaseTransportMixin.

verify_state() #

Verify if session was not yet opened. If it is, open it and call connections on_open

ConnectionInfo(ip, cookies, arguments, headers, path) #

Bases: object

Connection information object.

Will be passed to the on_open handler of your connection class.

Has few properties:

ip Caller IP address cookies Collection of cookies arguments Collection of the query string arguments headers Collection of headers sent by the browser that established this connection path Request uri path

get_argument(name) #

Return single argument by name

Return single cookie by its name

get_header(name) #

Return single header by its name

Session(conn, server, session_id, expiry = None) #

Bases: BaseSession, sessioncontainer.SessionMixin

SockJS session implementation.

Session constructor.

conn Default connection class server SockJSRouter instance session_id Session id expiry Session expiry time

close(code = 3000, message = 'Go away!') #

Close session.

code Closing code message Closing message

delay_heartbeat() #

Delay active heartbeat

flush() #

Flush message queue if there's an active connection running

on_delete(forced) #

Session expiration callback

forced If session item explicitly deleted, forced will be set to True. If item expired, will be set to False.

on_messages(msg_list) #

Handle incoming messages

msg_list Message list to process

remove_handler(handler) #

Detach active handler from the session

handler Handler to remove

send_jsonified(msg, stats = True) #

Send JSON-encoded message

msg JSON encoded string to send stats If set to True, will update statistics after operation completes

send_message(msg, stats = True, binary = False) #

Send or queue outgoing message

msg Message to send stats If set to True, will update statistics after operation completes

set_handler(handler, start_heartbeat = True) #

Set active handler for the session

handler Associate active Tornado handler with the session start_heartbeat Should session start heartbeat immediately

start_heartbeat() #

Reset hearbeat timer

stop_heartbeat() #

Stop active heartbeat

verify_state() #

Verify if session was not yet opened. If it is, open it and call connections on_open