# 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`

  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__`()

    Initiate to avoid AttributeErrors down the line

  property `cmdset_storage`
  property `id`
  `at_sync`()

    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)

    Hook called by sessionhandler when the session becomes authenticated.

    Parameters

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

  `at_disconnect`(reason=None)

    Hook called by sessionhandler when disconnecting this session.

  `get_account`()

    Get the account associated with this session

    Returns

      account (Account) – The associated Account.

  `get_puppet`()

    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`()

    Get puppet or account.

    Returns

      controller (Object or Account) –

      The puppet if one exists,

        otherwise return the account.

  `log`(message, channel=True)

    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`()

    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)

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

  `update_flags`(**kwargs)

    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)

    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)

    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)

    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)

    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)

    A dummy hook all objects with cmdsets need to have

  `nattributes`
  `attributes`
  `ndb_get`()

    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)

    Stop accidentally replacing the db object

    Parameters

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

  `ndb_del`()

    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)

    Dummy method to mimic the logged-in API.