コード例 #1
0
 def lineReceived(self, line):
     try:
         msg = message.parse(line)
         self.dispatch(msg)
     except error.Error as e:
         print "Error handling message: %s" % e
         msg = message.Message('error', {'message': str(e)})
         self.sendLine(str(msg))
         self.transport.loseConnection()
コード例 #2
0
ファイル: net.py プロジェクト: yuvalturg/ROSE
 def lineReceived(self, line):
     try:
         msg = message.parse(line)
         self.dispatch(msg)
     except error.Error as e:
         log.warning("Error handling message: %s", e)
         msg = message.Message('error', {'message': str(e)})
         self.sendLine(str(msg).encode('utf-8'))
         self.transport.loseConnection()
コード例 #3
0
ファイル: game.py プロジェクト: Abelarm/ROSE
 def drive(self):
     start = time.time()
     try:
         action = self.drive_func(self.world)
     except Exception:
         # Make it easy to detect and handle errors by crashing loudly. In
         # the past we used to print a traceback and continue, and students
         # had trouble detecting and handling errors.
         reactor.stop()
         raise
     response_time = time.time() - start
     msg = message.Message('drive', {
         "action": action,
         "response_time": response_time
     })
     self.client.send_message(msg)
コード例 #4
0
ファイル: game.py プロジェクト: Abelarm/ROSE
 def client_connected(self):
     log.info('client connected: joining as %s', self.name)
     msg = message.Message('join', {"name": self.name})
     self.client.send_message(msg)
コード例 #5
0
ファイル: net.py プロジェクト: yuvalturg/ROSE
 def add_watcher(self, watcher):
     self.clients.add(watcher)
     msg = message.Message("update", self.game.state())
     watcher.send_message(str(msg))
コード例 #6
0
 def update_clients(self):
     msg = message.Message('update', self.state())
     self.hub.broadcast(msg)
コード例 #7
0
 def update_players(self):
     msg = message.Message('update', self.state())
     self.server.broadcast(msg)
コード例 #8
0
 def client_connected(self):
     print 'client connected: joining as', self.name
     msg = message.Message('join', {"name": self.name})
     self.client.send_message(msg)
コード例 #9
0
ファイル: net.py プロジェクト: ruthersmith/ROSE
 def add_watcher(self, watcher):
     self.clients.add(watcher)
     game_state = message.Message("update", self.game.state())
     game_history = message.Message('history', {'todo': True})
     watcher.send_message(bytes(str(game_state), 'utf-8'))
     watcher.send_message(bytes(str(game_history), 'utf-8'))