diff --git a/evennia/server/serversession.py b/evennia/server/serversession.py index d714ca051d..79f1213ee4 100644 --- a/evennia/server/serversession.py +++ b/evennia/server/serversession.py @@ -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. diff --git a/evennia/server/sessionhandler.py b/evennia/server/sessionhandler.py index 64e54e9cbc..11f032c0a1 100644 --- a/evennia/server/sessionhandler.py +++ b/evennia/server/sessionhandler.py @@ -691,7 +691,22 @@ class ServerSessionHandler(SessionHandler): def data_in(self, session, **kwargs): """ - Data Portal -> Server. + We let the data take a "detour" to session.data_in + so the user can override and see it all in one place. + That method is responsible to in turn always call + this class' `sessionhandler.call_inputfunc` with the + (possibly processed) data. + + """ + if session: + session.data_in(**kwargs) + + def call_inputfuncs(self, session, **kwargs): + """ + Split incoming data into its inputfunc counterparts. + This should be called by the serversession.data_in + as sessionhandler.call_inputfunc(self, **kwargs). + We also intercept OOB communication here. Args: