Change ingoing message path to reroute through serversession.data_in before calling the inputfuncs. This allows users to view all incoming data in one place if they want to do eventual pre-processing. Resolves #1163.

This commit is contained in:
Griatch 2017-01-14 12:28:07 +01:00
parent 44bd403cc8
commit a403cc9576
2 changed files with 33 additions and 4 deletions

View file

@ -373,11 +373,25 @@ class ServerSession(Session):
"""
self.sessionhandler.data_out(self, **kwargs)
def data_in(self, **kwargs):
"""
Receiving data from the client, sending it off to
the respective inputfuncs.
Kwargs:
kwargs (any): Incoming data from protocol on
the form `{"commandname": ((args), {kwargs}),...}`
Notes:
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)`.
"""
self.sessionhandler.call_inputfuncs(self, **kwargs)
def msg(self, text=None, **kwargs):
"""
Wrapper to mimic msg() functionality of Objects and Players
(server sessions don't use data_in since incoming data is
handled by inputfuncs).
Wrapper to mimic msg() functionality of Objects and Players.
Args:
text (str): String input.