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.NDbHolder(obj, name, manager_name='attributes')[source]

Bases: object

Holder for allowing property access of attributes

__init__(obj, name, manager_name='attributes')[source]

Initialize self. See help(type(self)) for accurate signature.

get_all()[source]
property all
class evennia.server.serversession.NAttributeHandler(obj)[source]

Bases: object

NAttributeHandler version without recache protection. This stand-alone handler manages non-database saving. It is similar to AttributeHandler and is used by the .ndb handler in the same way as .db does for the AttributeHandler.

__init__(obj)[source]

Initialized on the object

has(key)[source]

Check if object has this attribute or not.

Parameters

key (str) – The Nattribute key to check.

Returns

has_nattribute (bool) – If Nattribute is set or not.

get(key, default=None)[source]

Get the named key value.

Parameters

key (str) – The Nattribute key to get.

Returns

the value of the Nattribute.

add(key, value)[source]

Add new key and value.

Parameters
  • key (str) – The name of Nattribute to add.

  • value (any) – The value to store.

remove(key)[source]

Remove Nattribute from storage.

Parameters

key (str) – The name of the Nattribute to remove.

clear()[source]

Remove all NAttributes from handler.

all(return_tuples=False)[source]

List the contents of the handler.

Parameters

return_tuples (bool, optional) – Defines if the Nattributes are returns as a list of keys or as a list of (key, value).

Returns

nattributes (list)

A list of keys [key, key, …] or a

list of tuples [(key, value), …] depending on the setting of return_tuples.

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.

__init__()[source]

Initiate to avoid AttributeErrors down the line

property cmdset_storage
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) – The associated Account.

get_puppet()[source]

Get the in-game character associated with this session.

Returns

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

get_character()

Get the in-game character associated with this session.

Returns

puppet (Object) – 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

any – A key:value pair 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

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.

  • kwargs (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]

A dummy hook all objects with cmdsets need to have

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.