Changed msg() to work with **kwargs rather than data dicts. Still not fully updated the portal side (also remember that keywords let through to the portal must not contain dbobjs, since the portal has no connection to the database).
This commit is contained in:
parent
1e96b13920
commit
4a5de04956
11 changed files with 59 additions and 34 deletions
|
|
@ -126,6 +126,14 @@ class OOBHandler(object):
|
|||
self.tracked = defaultdict(dict)
|
||||
self.oobstrings = ""
|
||||
|
||||
def parse_commanddict(self, dic):
|
||||
"""
|
||||
The command dict is on the form
|
||||
{functionname:((args), {kwargs}), ...}
|
||||
It is stored in text form as a pickle.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def _make_hash(self, callback_key, hashkey):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -183,11 +183,11 @@ class ServerSession(Session):
|
|||
self.update_session_counters()
|
||||
execute_cmd = data_in # alias
|
||||
|
||||
def data_out(self, msg, data=None):
|
||||
def data_out(self, text=None, **kwargs):
|
||||
"""
|
||||
Send Evennia -> Player
|
||||
"""
|
||||
self.sessionhandler.data_out(self, msg, data)
|
||||
self.sessionhandler.data_out(self, text=text, **kwargs)
|
||||
|
||||
def oob_data_in(self, data):
|
||||
"""
|
||||
|
|
@ -276,9 +276,9 @@ class ServerSession(Session):
|
|||
#def disconnect(self):
|
||||
# "alias for session_disconnect"
|
||||
# self.session_disconnect()
|
||||
def msg(self, string='', data=None):
|
||||
def msg(self, text='', **kwargs):
|
||||
"alias for at_data_out"
|
||||
self.data_out(string, data=data)
|
||||
self.data_out(text=text, **kwargs)
|
||||
|
||||
|
||||
# Dummy API hooks for use during non-loggedin operation
|
||||
|
|
|
|||
|
|
@ -15,7 +15,14 @@ There are two similar but separate stores of sessions:
|
|||
import time
|
||||
from django.conf import settings
|
||||
from src.commands.cmdhandler import CMD_LOGINSTART
|
||||
from src.utils.utils import variable_from_module
|
||||
from src.utils.utils import variable_from_module, to_str
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except ImportError:
|
||||
import pickle
|
||||
|
||||
dumps = lambda data: to_str(pickle.dumps(data, pickle.HIGHEST_PROTOCOL))
|
||||
loads = lambda data: pickle.loads(to_str(data))
|
||||
|
||||
# delayed imports
|
||||
_PlayerDB = None
|
||||
|
|
@ -350,20 +357,21 @@ class ServerSessionHandler(SessionHandler):
|
|||
for sess in self.sessions.values():
|
||||
self.data_out(sess, message)
|
||||
|
||||
def data_out(self, session, string="", data=""):
|
||||
def data_out(self, session, text="", **kwargs):
|
||||
"""
|
||||
Sending data Server -> Portal
|
||||
"""
|
||||
self.server.amp_protocol.call_remote_MsgServer2Portal(sessid=session.sessid,
|
||||
msg=string,
|
||||
data=data)
|
||||
def data_in(self, sessid, string="", data=""):
|
||||
msg=text,
|
||||
data=kwargs)
|
||||
def data_in(self, sessid, text="", data=""):
|
||||
"""
|
||||
Data Portal -> Server
|
||||
"""
|
||||
session = self.sessions.get(sessid, None)
|
||||
if session:
|
||||
session.data_in(string)
|
||||
kwargs = data if data else {}
|
||||
session.data_in(text, **kwargs)
|
||||
|
||||
# ignore 'data' argument for now; this is otherwise the place
|
||||
# to put custom effects on the server due to data input, e.g.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue