Added @sessions command for viewing active sessions connected to a given account.

This commit is contained in:
Griatch 2013-02-17 20:21:23 +01:00
parent 25505d69a6
commit 458e3e7599
4 changed files with 53 additions and 5 deletions

View file

@ -678,13 +678,18 @@ class ObjectDB(TypedObject):
data (object): an optional data object that may or may not
be used by the protocol.
sessid (int): sessid to relay to, if any.
If set to 0 (default), use self.sessid automatically
If set to 0 (default), use either from_obj.sessid (if set) or self.sessid automatically
If None, echo to all connected sessions
"""
if _GA(self, 'player'):
# note that we must call the player *typeclass'* msg(), otherwise one couldn't overload it.
_GA(_GA(self, 'player'), "typeclass").msg(msg, from_obj=from_obj, data=data,
sessid=(sessid==0 and _GA(self, "sessid") or sessid or None))
if sessid == 0:
sessid = None
if from_obj and hasattr(from_obj, "sessid"):
sessid = from_obj.sessid
elif hasattr(self, "sessid"):
sessid = self.sessid
_GA(_GA(self, 'player'), "typeclass").msg(msg, from_obj=from_obj, data=data, sessid=sessid)
def emit_to(self, message, from_obj=None, data=None):
"Deprecated. Alias for msg"

View file

@ -216,7 +216,7 @@ class Object(TypeClass):
"""
return self.dbobj.execute_cmd(raw_string, sessid=sessid)
def msg(self, message, from_obj=None, data=None):
def msg(self, message, from_obj=None, data=None, sessid=0):
"""
Emits something to any sessions attached to the object.
@ -224,8 +224,10 @@ class Object(TypeClass):
from_obj (obj): object that is sending.
data (object): an optional data object that may or may not
be used by the protocol.
sessid: optional session target. If sessid=0, the session will
default to self.sessid or from_obj.sessid.
"""
self.dbobj.msg(message, from_obj=from_obj, data=data)
self.dbobj.msg(message, from_obj=from_obj, data=data, sessid=0)
def msg_contents(self, message, exclude=None, from_obj=None, data=None):
"""