Server/Router

class server.Router(config, dbman)[source]

This class handles interfacing between the server backends and the user command consoles. It manages a lookup table of connected users and their consoles, and handles passing messages between them.

Variables
  • users – Dictionary of connected users and their consoles, as well as the protocols they are connected by.

  • single_user – Whether we are running in single-user mode. Hard-coded here to False.

  • telnet_factory – The active Autobahn telnet server factory.

  • websocket_factory – The active Autobahn websocket server factory.

__init__(config, dbman)[source]

Router Initializer

broadcast_all(msg)[source]

Broadcast All

Broadcast a message to all logged in users.

Parameters

msg – Message to send.

Returns

True

broadcast_room(room, msg)[source]

Broadcast Room

Broadcast a message to all logged in users in the given room.

Parameters
  • room – Room ID.

  • msg – Message to send.

Returns

True

message(peer, msg, _nbsp=False)[source]

Message Peer

Message a user by their internal peer name.

Parameters
  • peer – Internal peer name.

  • msg – Message to send.

  • _nbsp – Will insert non-breakable spaces for formatting on the websocket frontend.

Returns

True

register(peer, service)[source]

Register User

Parameters
  • peer – Internal peer name.

  • service – Service type. “telnet” or “websocket”.

Returns

True

unregister(peer)[source]

Unregister and Logout User

Parameters

peer – Internal peer name.

Returns

True if succeeded, False if no such user.