More OOBhandler cleanup

This commit is contained in:
Griatch 2015-02-13 00:18:24 +01:00
parent d4b5533c20
commit fb5b2a8641
2 changed files with 26 additions and 15 deletions

View file

@ -3,11 +3,18 @@ Out-of-band default plugin commands available for OOB handler.
This module implements commands as defined by the MSDP standard This module implements commands as defined by the MSDP standard
(http://tintin.sourceforge.net/msdp/), but is independent of the (http://tintin.sourceforge.net/msdp/), but is independent of the
actual transfer protocol (webclient, MSDP, GMCP etc). actual transfer protocol (webclient, MSDP, GMCP etc). It also
implements several OOB commands unique to Evennia (both some
external and some for testing)
This module is pointed to by settings.OOB_PLUGIN_MODULES. It must The available OOB commands can be extended by changing
contain a global dictionary CMD_MAP which is a dictionary that maps
the call available in the OOB call to a function in this module. `settings.OOB_PLUGIN_MODULES`
This module must contain a global dictionary CMD_MAP. This is a
dictionary that maps the call available in the OOB call to a function
in this module (this allows you to map multiple oob cmdnames to a
single actual Python function, for example).
For example, if the OOB strings received looks like this: For example, if the OOB strings received looks like this:
@ -21,7 +28,7 @@ oob functions have the following call signature:
function(oobhandler, session, *args, **kwargs) function(oobhandler, session, *args, **kwargs)
here, oobhandler is a back-reference to the central oob handler (this where oobhandler is a back-reference to the central oob handler (this
allows for deactivating itself in various ways), session is the active allows for deactivating itself in various ways), session is the active
session and *args, **kwargs are what is sent from the oob call. session and *args, **kwargs are what is sent from the oob call.
@ -36,9 +43,10 @@ Data is usually returned to the user via a return OOB call:
session.msg(oob=(oobcmdname, (args,), {kwargs})) session.msg(oob=(oobcmdname, (args,), {kwargs}))
oobcmdnames (like "MSDP.LISTEN" / "LISTEN" above) are case-sensitive. Note that args, Oobcmdnames (like "MSDP.LISTEN" / "LISTEN" above) are case-sensitive.
kwargs must be iterable. Non-iterables will be interpreted as a new Note that args, kwargs must be iterable. Non-iterables will be
command name (you can send multiple oob commands with one msg() call)) interpreted as a new command name (you can send multiple oob commands
with one msg() call))
Evennia introduces two internal extensions to MSDP, and that is the Evennia introduces two internal extensions to MSDP, and that is the
MSDP_ARRAY and MSDP_TABLE commands. These are never sent across the MSDP_ARRAY and MSDP_TABLE commands. These are never sent across the
@ -136,10 +144,10 @@ def oob_unrepeat(oobhandler, session, oobfuncname, interval):
# #
# MSDP standard commands # MSDP protocol standard commands
# #
# MSDP suggests the following standard name conventions for making
# MSDP recommends the following standard name conventions for making different properties available to the player # different properties available to the player
# "CHARACTER_NAME", "SERVER_ID", "SERVER_TIME", "AFFECTS", "ALIGNMENT", "EXPERIENCE", "EXPERIENCE_MAX", "EXPERIENCE_TNL", # "CHARACTER_NAME", "SERVER_ID", "SERVER_TIME", "AFFECTS", "ALIGNMENT", "EXPERIENCE", "EXPERIENCE_MAX", "EXPERIENCE_TNL",
# "HEALTH", "HEALTH_MAX", "LEVEL", "RACE", "CLASS", "MANA", "MANA_MAX", "WIMPY", "PRACTICE", "MONEY", "MOVEMENT", # "HEALTH", "HEALTH_MAX", "LEVEL", "RACE", "CLASS", "MANA", "MANA_MAX", "WIMPY", "PRACTICE", "MONEY", "MOVEMENT",
@ -342,6 +350,10 @@ def oob_list(oobhandler, session, mode, *args, **kwargs):
session.msg(oob=("err", ("LIST", "Unsupported mode",))) session.msg(oob=("err", ("LIST", "Unsupported mode",)))
#
# Cmd mapping
#
# this maps the commands to the names available to use from # this maps the commands to the names available to use from
# the oob call. The standard MSDP commands are capitalized # the oob call. The standard MSDP commands are capitalized
# as per the protocol, Evennia's own commands are not. # as per the protocol, Evennia's own commands are not.

View file

@ -34,7 +34,6 @@ messages.
""" """
from inspect import isfunction
from collections import defaultdict from collections import defaultdict
from django.conf import settings from django.conf import settings
from evennia.server.models import ServerConfig from evennia.server.models import ServerConfig
@ -42,7 +41,7 @@ from evennia.server.sessionhandler import SESSIONS
from evennia.scripts.tickerhandler import TickerHandler from evennia.scripts.tickerhandler import TickerHandler
from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj, unpack_dbobj from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj, unpack_dbobj
from evennia.utils import logger from evennia.utils import logger
from evennia.utils.utils import all_from_module, make_iter from evennia.utils.utils import make_iter
_SA = object.__setattr__ _SA = object.__setattr__
_GA = object.__getattribute__ _GA = object.__getattribute__
@ -56,7 +55,7 @@ for mod in make_iter(settings.OOB_PLUGIN_MODULES):
# get the command to receive eventual error strings # get the command to receive eventual error strings
_OOB_ERROR = _OOB_FUNCS.get("oob_error", None) _OOB_ERROR = _OOB_FUNCS.get("oob_error", None)
if not _OOB_ERROR: if not _OOB_ERROR:
# create default oob error message function # no custom error set; create default oob error message function
def oob_error(oobhandler, session, errmsg, *args, **kwargs): def oob_error(oobhandler, session, errmsg, *args, **kwargs):
""" """
Fallback error handler. This will be used if no custom Fallback error handler. This will be used if no custom