evennia.server.serversession

This defines a the Server’s generic session object. This object represents a connection to the outside world but don’t know any details about how the connection actually happens (so it’s the same for telnet, web, ssh etc).

It is stored on the Server side (as opposed to protocol-specific sessions which are stored on the Portal side)

class evennia.server.serversession.ServerSession[source]

Bases: evennia.server.session.Session

This class represents an account’s session and is a template for individual protocols to communicate with Evennia.

Each account gets a session assigned to them whenever they connect to the game server. All communication between game and account goes through their session.

cmdset_provider_order = 0
cmdset_provider_error_order = 50
cmdset_provider_type = 'session'
__init__()[source]

Initiate to avoid AttributeErrors down the line

property cmdset_storage
get_cmdset_providers() → dict[source]

Overrideable method which returns a dictionary of every kind of object which has a cmdsethandler linked to this ServerSession, and should participate in cmdset merging.

In all normal cases, that’s the Session itself, and possibly an account and puppeted

object.

Returns

dict[str, CmdSetProvider] – The CmdSetProviders linked to this Object.

property id
at_sync()[source]

This is called whenever a session has been resynced with the portal. At this point all relevant attributes have already been set and self.account been assigned (if applicable).

Since this is often called after a server restart we need to set up the session as it was.

at_login(account)[source]

Hook called by sessionhandler when the session becomes authenticated.

Parameters

account (Account) – The account associated with the session.

at_disconnect(reason=None)[source]

Hook called by sessionhandler when disconnecting this session.

get_account()[source]

Get the account associated with this session

Returns

account (Account or None) – The associated Account.

get_puppet()[source]

Get the in-game character associated with this session.

Returns

puppet (Object or None) – The puppeted object, if any.

get_character()

Get the in-game character associated with this session.

Returns

puppet (Object or None) – The puppeted object, if any.

get_puppet_or_account()[source]

Get puppet or account.

Returns

controller (Object or Account)

The puppet if one exists,

otherwise return the account.

log(message, channel=True)[source]

Emits session info to the appropriate outputs and info channels.

Parameters
  • message (str) – The message to log.

  • channel (bool, optional) – Log to the CHANNEL_CONNECTINFO channel in addition to the server log.

get_client_size()[source]

Return eventual eventual width and height reported by the client. Note that this currently only deals with a single client window (windowID==0) as in a traditional telnet session.

update_session_counters(idle=False)[source]

Hit this when the user enters a command in order to update idle timers and command counters.

update_flags(**kwargs)[source]

Update the protocol_flags and sync them with Portal.

Keyword Arguments

protocol_flag (any) – A key and value to set in the protocol_flags dictionary.

Notes

Since protocols can vary, no checking is done as to the existene of the flag or not. The input data should have been validated before this call.

data_out(**kwargs)[source]

Sending data from Evennia->Client

Keyword Arguments
  • text (str or tuple) –

  • any (str or tuple) – Send-commands identified by their keys. Or “options”, carrying options for the protocol(s).

data_in(**kwargs)[source]

Receiving data from the client, sending it off to the respective inputfuncs.

Keyword Arguments

kwargs (any) – Incoming data from protocol on the form {“commandname”: ((args), {kwargs}),…}

Notes

This method is here in order to give the user a single place to catch and possibly process all incoming data from the client. It should usually always end by sending this data off to self.sessionhandler.call_inputfuncs(self, **kwargs).

msg(text=None, **kwargs)[source]

Wrapper to mimic msg() functionality of Objects and Accounts.

Parameters

text (str) – String input.

Keyword Arguments

any (str or tuple) – Send-commands identified by their keys. Or “options”, carrying options for the protocol(s).

execute_cmd(raw_string, session=None, **kwargs)[source]

Do something as this object. This method is normally never called directly, instead incoming command instructions are sent to the appropriate inputfunc already at the sessionhandler level. This method allows Python code to inject commands into this stream, and will lead to the text inputfunc be called.

Parameters
  • raw_string (string) – Raw command input

  • session (Session) – This is here to make API consistent with Account/Object.execute_cmd. If given, data is passed to that Session, otherwise use self.

Keyword Arguments
  • keyword arguments will be added to the found command (Other) –

  • instace as variables before it executes. This is (object) –

  • by default Evennia but may be used to set flags and (unused) –

  • operating paramaters for commands at run-time. (change) –

at_cmdset_get(**kwargs)[source]

Called just before cmdsets on this object are requested by the command handler. If changes need to be done on the fly to the cmdset before passing them on to the cmdhandler, this is the place to do it. This is called also if the object currently have no cmdsets.

Keyword Arguments
  • caller (Object, Account or Session) – The object requesting the cmdsets.

  • current (CmdSet) – The current merged cmdset.

  • force_init (bool) – If True, force a re-build of the cmdset. (seems unused)

  • **kwargs – Arbitrary input for overloads.

get_cmdsets(caller, current, **kwargs)[source]

Called by the CommandHandler to get a list of cmdsets to merge.

Parameters
  • caller (obj) – The object requesting the cmdsets.

  • current (cmdset) – The current merged cmdset.

  • **kwargs – Arbitrary input for overloads.

Returns

tuple – A tuple of (current, cmdsets), which is probably self.cmdset.current and self.cmdset.cmdset_stack

nattributes[source]
attributes[source]
ndb_get()[source]

A non-persistent store (ndb: NonDataBase). Everything stored to this is guaranteed to be cleared when a server is shutdown. Syntax is same as for the _get_db_holder() method and property, e.g. obj.ndb.attr = value etc.

ndb_set(value)[source]

Stop accidentally replacing the db object

Parameters

value (any) – A value to store in the ndb.

ndb_del()[source]

Stop accidental deletion.

property ndb

NonDataBase). Everything stored to this is guaranteed to be cleared when a server is shutdown. Syntax is same as for the _get_db_holder() method and property, e.g. obj.ndb.attr = value etc.

Type

A non-persistent store (ndb

property db

NonDataBase). Everything stored to this is guaranteed to be cleared when a server is shutdown. Syntax is same as for the _get_db_holder() method and property, e.g. obj.ndb.attr = value etc.

Type

A non-persistent store (ndb

access(*args, **kwargs)[source]

Dummy method to mimic the logged-in API.

get_display_name(*args, **kwargs)[source]