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
[源代码]¶ 基类:
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'¶
-
property
cmdset_storage
¶
-
get_cmdset_providers
() → dict[源代码]¶ 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.
- 返回
dict[str, CmdSetProvider] – The CmdSetProviders linked to this Object.
-
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.
- 参数
account (Account) – The account associated with the session.
-
get_account
()[源代码]¶ Get the account associated with this session
- 返回
account (Account or None) – The associated Account.
-
get_puppet
()[源代码]¶ Get the in-game character associated with this session.
- 返回
puppet (Object or None) – The puppeted object, if any.
-
get_character
()¶ Get the in-game character associated with this session.
- 返回
puppet (Object or None) – The puppeted object, if any.
-
get_puppet_or_account
()[源代码]¶ Get puppet or account.
- 返回
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.
- 参数
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.
- 关键字参数
protocol_flag (any) – A key and value to set in the protocol_flags dictionary.
提示
Since protocols can vary, no checking is done as to the existence of the flag or not. The input data should have been validated before this call.
-
data_out
(**kwargs)[源代码]¶ Sending data from Evennia->Client
- 关键字参数
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.
- 关键字参数
kwargs (any) – Incoming data from protocol on the form {“commandname”: ((args), {kwargs}),…}
提示
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.
- 参数
text (str) – String input.
- 关键字参数
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.
- 参数
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 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)[源代码]¶ 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.
-
get_cmdsets
(caller, current, **kwargs)[源代码]¶ Called by the CommandHandler to get a list of cmdsets to merge.
- 参数
caller (obj) – The object requesting the cmdsets.
current (cmdset) – The current merged cmdset.
**kwargs – Arbitrary input for overloads.
- 返回
tuple – A tuple of (current, cmdsets), which is probably self.cmdset.current and self.cmdset.cmdset_stack
-
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
- 参数
value (any) – A value to store in the ndb.
-
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
-