More tweaks to the oob mechanism; renamed oob_defaults to oob_msdp
This commit is contained in:
parent
4c650a44a6
commit
584d1095ad
3 changed files with 26 additions and 16 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Out-of-band default plugin functions for the OOB handler
|
Out-of-band default plugin commands available for OOB handler. This
|
||||||
|
follows the standards defined by the MSDP out-of-band protocol
|
||||||
|
(http://tintin.sourceforge.net/msdp/)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
@ -187,19 +189,19 @@ def LIST(oobhandler, session, mode, *args, **kwargs):
|
||||||
mode = mode.upper()
|
mode = mode.upper()
|
||||||
# the first return argument is treated by the msdp protocol as the name of the msdp array to return
|
# the first return argument is treated by the msdp protocol as the name of the msdp array to return
|
||||||
if mode == "COMMANDS":
|
if mode == "COMMANDS":
|
||||||
session.msg(oob=("list", ("COMMANDS", "LIST", "REPORT", "UNREPORT", "SEND", "RESET")))
|
session.msg(oob=("list", ("COMMANDS", "LIST", "REPORT", "UNREPORT", "SEND"))) # RESET
|
||||||
elif mode == "LISTS":
|
elif mode == "LISTS":
|
||||||
session.msg(oob=("list", ("LISTS", "REPORTABLE_VARIABLES","REPORTED_VARIABLES", "SENDABLE_VARIABLES"))) #CONFIGURABLE_VARIABLES
|
session.msg(oob=("list", ("LISTS", "REPORTABLE_VARIABLES","REPORTED_VARIABLES", "SENDABLE_VARIABLES"))) #CONFIGURABLE_VARIABLES
|
||||||
elif mode == "REPORTABLE_VARIABLES":
|
elif mode == "REPORTABLE_VARIABLES":
|
||||||
session.msg(oob=("list", ("REPORTABLE_VARIABLES",) + tuple(key for key in OOB_REPORTABLE.keys())))
|
session.msg(oob=("list", ("REPORTABLE_VARIABLES",) + tuple(key for key in OOB_REPORTABLE.keys())))
|
||||||
elif mode == "REPORTED_VARIABLES":
|
elif mode == "REPORTED_VARIABLES":
|
||||||
pass
|
session.msg(oob=("list", ("REPORTED_VARIABLES",) + tuple(oobhandler.get_all_tracked(session))))
|
||||||
elif mode == "SENDABLE_VARIABLES":
|
elif mode == "SENDABLE_VARIABLES":
|
||||||
pass
|
session.msg(oob=("list", ("SENDABLE_VARIABLES",) + tuple(key for key in OOB_REPORTABLE.keys())))
|
||||||
elif mode == "CONFIGURABLE_VARIABLES":
|
#elif mode == "CONFIGURABLE_VARIABLES":
|
||||||
pass
|
# pass
|
||||||
else:
|
else:
|
||||||
session.msg(oob=("list", ("wrong mode",)))
|
session.msg(oob=("list", ("unsupported mode",)))
|
||||||
|
|
||||||
|
|
||||||
def send(oobhandler, session, *args, **kwargs):
|
def send(oobhandler, session, *args, **kwargs):
|
||||||
|
|
@ -9,10 +9,10 @@ pieces of functionality:
|
||||||
are valid for this use.
|
are valid for this use.
|
||||||
repeat func execution - the oob protocol can request a given function be executed repeatedly
|
repeat func execution - the oob protocol can request a given function be executed repeatedly
|
||||||
at a regular interval.
|
at a regular interval.
|
||||||
tracking - the oob protocol can request Evennia to track changes to fields/properties on
|
tracking - the oob protocol can request Evennia to track changes to fields on
|
||||||
objects, as well as changes in Attributes. This is done by dynamically adding
|
objects, as well as changes in Attributes. This is done by dynamically adding
|
||||||
tracker-objects on entities. The behaviour of those objects can be customized
|
tracker-objects on entities. The behaviour of those objects can be customized
|
||||||
via settings.OOB_PLUGIN_MODULE.OOB_TRACKERS.
|
via settings.OOB_PLUGIN_MODULE
|
||||||
|
|
||||||
oob functions have the following call signature:
|
oob functions have the following call signature:
|
||||||
function(caller, *args, **kwargs)
|
function(caller, *args, **kwargs)
|
||||||
|
|
@ -278,6 +278,13 @@ class OOBHandler(object):
|
||||||
store_key = (pack_dbobj(obj), sessid, fieldname)
|
store_key = (pack_dbobj(obj), sessid, fieldname)
|
||||||
self.oob_tracker_storage.pop(store_key, None)
|
self.oob_tracker_storage.pop(store_key, None)
|
||||||
|
|
||||||
|
def get_all_tracked(session):
|
||||||
|
"""
|
||||||
|
Get the names of all variables this session is tracking.
|
||||||
|
"""
|
||||||
|
sessid = session.sessid
|
||||||
|
return [key[2].lstrip("db_") for key in self.oob_tracker_storage.keys() if key[1] == sessid]
|
||||||
|
|
||||||
def track_field(self, obj, sessid, field_name, trackerclass):
|
def track_field(self, obj, sessid, field_name, trackerclass):
|
||||||
"""
|
"""
|
||||||
Shortcut wrapper method for specifically tracking a database field.
|
Shortcut wrapper method for specifically tracking a database field.
|
||||||
|
|
@ -328,7 +335,7 @@ class OOBHandler(object):
|
||||||
try:
|
try:
|
||||||
obj = obj.dbobj
|
obj = obj.dbobj
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
passj
|
||||||
store_obj = pack_dbobj(obj)
|
store_obj = pack_dbobj(obj)
|
||||||
store_key = (store_obj, sessid, func_key, interval)
|
store_key = (store_obj, sessid, func_key, interval)
|
||||||
# prepare to store
|
# prepare to store
|
||||||
|
|
@ -348,13 +355,14 @@ class OOBHandler(object):
|
||||||
self.oob_repeat_storage.pop(store_key, None)
|
self.oob_repeat_storage.pop(store_key, None)
|
||||||
|
|
||||||
def msg(self, sessid, funcname, *args, **kwargs):
|
def msg(self, sessid, funcname, *args, **kwargs):
|
||||||
"Shortcut to relay oob data back to portal"
|
"Shortcut to relay oob data back to portal. Used by oob functions."
|
||||||
session = self.sessionhandler.session_from_sessid(sessid)
|
session = self.sessionhandler.session_from_sessid(sessid)
|
||||||
#print "oobhandler msg:", sessid, session, funcname, args, kwargs
|
#print "oobhandler msg:", sessid, session, funcname, args, kwargs
|
||||||
if session:
|
if session:
|
||||||
session.msg(oob=(funcname, args, kwargs))
|
session.msg(oob=(funcname, args, kwargs))
|
||||||
|
|
||||||
# access method - called from msg()
|
# access method - called from session.msg()
|
||||||
|
|
||||||
|
|
||||||
def execute_cmd(self, session, func_key, *args, **kwargs):
|
def execute_cmd(self, session, func_key, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -196,13 +196,13 @@ PORTAL_SERVICES_PLUGIN_MODULES = []
|
||||||
# Module holding MSSP meta data. This is used by MUD-crawlers to determine
|
# Module holding MSSP meta data. This is used by MUD-crawlers to determine
|
||||||
# what type of game you are running, how many players you have etc.
|
# what type of game you are running, how many players you have etc.
|
||||||
MSSP_META_MODULE = ""
|
MSSP_META_MODULE = ""
|
||||||
# Module holding OOB (Out of Band) hook objects. This allows for customization
|
|
||||||
# and expansion of which hooks OOB protocols are allowed to call on the server
|
|
||||||
# protocols for attaching tracker hooks for when various object field change
|
|
||||||
OOB_PLUGIN_MODULE = "src.server.oob_defaults"
|
|
||||||
# Tuple of modules implementing lock functions. All callable functions
|
# Tuple of modules implementing lock functions. All callable functions
|
||||||
# inside these modules will be available as lock functions.
|
# inside these modules will be available as lock functions.
|
||||||
LOCK_FUNC_MODULES = ("src.locks.lockfuncs",)
|
LOCK_FUNC_MODULES = ("src.locks.lockfuncs",)
|
||||||
|
# Module holding OOB (Out of Band) hook objects. This allows for customization
|
||||||
|
# and expansion of which hooks OOB protocols are allowed to call on the server
|
||||||
|
# protocols for attaching tracker hooks for when various object field change
|
||||||
|
OOB_PLUGIN_MODULE = "src.server.oob_msdp"
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Default command sets
|
# Default command sets
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue