laneya

multiplayer roguelike game
git clone https://git.ce9e.org/laneya.git

commit
3c07b73d144b0855d8f95f5067931fd52f66cfcb
parent
34606df1dad98c3923ba88d97fbbd520029c6304
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2014-10-05 08:57
move client protocol extension to protocol

Diffstat

M laneya/client.py 7 -------
M laneya/protocol.py 9 +++++++--

2 files changed, 7 insertions, 9 deletions


diff --git a/laneya/client.py b/laneya/client.py

@@ -14,13 +14,6 @@ def _print(s):
   14    14 
   15    15 
   16    16 class ClientProtocol(protocol.ClientProtocol):
   17    -1     def setup(self, user):
   18    -1         self.user = user
   19    -1 
   20    -1     def sendRequest(self, action, **kwargs):
   21    -1         return protocol.ClientProtocol.sendRequest(
   22    -1             self, self.user, action, **kwargs)
   23    -1 
   24    17     def updateReceived(self, action, **kwargs):  # TODO
   25    18         print(action, kwargs)
   26    19 

diff --git a/laneya/protocol.py b/laneya/protocol.py

@@ -178,6 +178,10 @@ class ClientProtocol(BaseProtocol):
  178   178     def __init__(self):
  179   179         self._responseDeferreds = {}
  180   180 
   -1   181     def setup(self, user):
   -1   182         """Setup the user for this connection."""
   -1   183         self.user = user
   -1   184 
  181   185     def jsonReceived(self, message):
  182   186         if message['type'] == 'response':
  183   187             self.validate_message(message, ['data', 'key', 'status', 'type'])
@@ -212,12 +216,13 @@ class ClientProtocol(BaseProtocol):
  212   216         except KeyError:
  213   217             pass
  214   218 
  215    -1     def sendRequest(self, user, action, **kwargs):
   -1   219     def sendRequest(self, action, **kwargs):
  216   220         """Send a request and get a promise yielding the response."""
   -1   221 
  217   222         data = {
  218   223             'type': 'request',
  219   224             'key': generate_key(),
  220    -1             'user': user,
   -1   225             'user': self.user,
  221   226             'action': action,
  222   227             'data': kwargs,
  223   228         }