- commit
- 693d480267073becb7504b0b063b25fb520cda4c
- parent
- 4a12cede8bbaa688a2d7e94f0db20a7e5d97cfe8
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2014-10-04 09:08
rename 'command' to 'action'
Diffstat
| M | laneya/client.py | 4 | ++-- |
| M | laneya/protocol.py | 20 | ++++++++++---------- |
| M | laneya/server.py | 10 | +++++----- |
3 files changed, 17 insertions, 17 deletions
diff --git a/laneya/client.py b/laneya/client.py
@@ -13,8 +13,8 @@ def _print(s): 13 13 14 14 15 15 class ClientProtocol(protocol.Protocol):16 -1 def updateReceived(self, command, **kwargs): # TODO17 -1 print(command, kwargs)-1 16 def updateReceived(self, action, **kwargs): # TODO -1 17 print(action, kwargs) 18 18 19 19 20 20 def connected(protocol): # TODO
diff --git a/laneya/protocol.py b/laneya/protocol.py
@@ -108,17 +108,17 @@ class Protocol(JSONProtocol): 108 108 def __init__(self): 109 109 self._responseDeferreds = {} 110 110111 -1 def requestReceived(self, command, **kwargs):-1 111 def requestReceived(self, action, **kwargs): 112 112 """Overwrite this on the server implementation.""" 113 113 raise NotImplementedError 114 114115 -1 def updateReceived(self, command, **kwargs):-1 115 def updateReceived(self, action, **kwargs): 116 116 """Overwrite this on the client implementation.""" 117 117 raise NotImplementedError 118 118119 -1 def _requestReceived(self, key, command, **data):-1 119 def _requestReceived(self, key, action, **data): 120 120 try:121 -1 response = self.requestReceived(command, **data)-1 121 response = self.requestReceived(action, **data) 122 122 except InvalidError as err: 123 123 return self._sendResponse(key, 'invalid', message=str(err)) 124 124 except IllegalError as err: @@ -133,7 +133,7 @@ class Protocol(JSONProtocol): 133 133 if message['type'] == 'request': 134 134 self._requestReceived( 135 135 message['key'],136 -1 message['command'],-1 136 message['action'], 137 137 **message['data']) 138 138 elif message['type'] == 'response': 139 139 key = message['key'] @@ -148,16 +148,16 @@ class Protocol(JSONProtocol): 148 148 else: 149 149 d.reject(response) 150 150 elif message['type'] == 'update':151 -1 self.updateReceived(message['command'], **message['data'])-1 151 self.updateReceived(message['action'], **message['data']) 152 152 else: 153 153 log.err('Message type not known: %s' % message['type']) 154 154155 -1 def sendRequest(self, command, **kwargs):-1 155 def sendRequest(self, action, **kwargs): 156 156 """Send a request and get a promise yielding the response.""" 157 157 data = { 158 158 'type': 'request', 159 159 'key': generate_key(),160 -1 'command': command,-1 160 'action': action, 161 161 'data': kwargs, 162 162 } 163 163 self.sendJSON(data) @@ -175,11 +175,11 @@ class Protocol(JSONProtocol): 175 175 } 176 176 self.sendJSON(data) 177 177178 -1 def sendUpdate(self, command, **kwargs):-1 178 def sendUpdate(self, action, **kwargs): 179 179 """Send an update.""" 180 180 data = { 181 181 'type': 'update',182 -1 'command': command,-1 182 'action': action, 183 183 'data': kwargs, 184 184 } 185 185 self.sendJSON(data)
diff --git a/laneya/server.py b/laneya/server.py
@@ -18,17 +18,17 @@ class ServerProtocol(protocol.Protocol): 18 18 def connectionLost(self, reason): 19 19 self.factory.connections.remove(self) 20 2021 -1 def broadcastUpdate(self, command, **kwargs):-1 21 def broadcastUpdate(self, action, **kwargs): 22 22 """Broadcast an update to all connected clients.""" 23 23 24 24 for connection in self.factory.connections:25 -1 connection.sendUpdate(command, **kwargs)-1 25 connection.sendUpdate(action, **kwargs) 26 2627 -1 def requestReceived(self, command, **kwargs): # TODO28 -1 if command == 'echo':-1 27 def requestReceived(self, action, **kwargs): # TODO -1 28 if action == 'echo': 29 29 return kwargs 30 30 else:31 -1 self.broadcastUpdate(command, **kwargs)-1 31 self.broadcastUpdate(action, **kwargs) 32 32 return {} 33 33 34 34