コード例 #1
0
ファイル: bnb.py プロジェクト: griels/pypy-sc
 def _closeIdleConnections(self):
     t = time.time() - 20.0  #20 seconds until considered idle
     for sessionid, sm in self._serverMessage.items():
         if sm.last_active < t:
             log("Close connection with sessionid %s because it was idle for %.1f seconds"
                 % (sessionid, time.time() - sm.last_active))
             if sm.socket is not None:
                 sm.socket.close()
             del self._serverMessage[sessionid]
コード例 #2
0
ファイル: bnb.py プロジェクト: TheDunn/flex-pypy
 def _closeIdleConnections(self):
     t = time.time() - 20.0 #20 seconds until considered idle
     for sessionid, sm in self._serverMessage.items():
         if sm.last_active < t:
             log("Close connection with sessionid %s because it was idle for %.1f seconds" % (
                 sessionid, time.time() - sm.last_active))
             if sm.socket is not None:
                 sm.socket.close()
             del self._serverMessage[sessionid]
コード例 #3
0
ファイル: bnb.py プロジェクト: antoine1fr/pygirl
 def getport(self):
     if hasattr(self, '_port'):
         return self._port
     try:
         port = re.findall('value=".*"', urllib.urlopen('http://%s:8000' % self.host).read())[0]
         port = int(port[7:-1])
     except IOError:
         log("ERROR: Can't connect to BnB server on %s:8000" % self.host)
         raise IOError
     except IndexError:
         log("ERROR: Connected to BnB server but unable to detect a running game")
         raise IOError
     self._port = port
     return port
コード例 #4
0
ファイル: bnb.py プロジェクト: griels/pypy-sc
 def getport(self):
     if hasattr(self, '_port'):
         return self._port
     try:
         port = re.findall(
             'value=".*"',
             urllib.urlopen('http://%s:8000' % self.host).read())[0]
         port = int(port[7:-1])
     except IOError:
         log("ERROR: Can't connect to BnB server on %s:8000" % self.host)
         raise IOError
     except IndexError:
         log("ERROR: Connected to BnB server but unable to detect a running game"
             )
         raise IOError
     self._port = port
     return port
コード例 #5
0
ファイル: bnb.py プロジェクト: TheDunn/flex-pypy
 def remove_player(self, player_id=0, sessionid=""):
     log("Remove player " + player_id)
     socket = self.sessionSocket(sessionid)
     socket.send(message(CMSG_REMOVE_PLAYER, int(player_id)))
コード例 #6
0
ファイル: bnb.py プロジェクト: TheDunn/flex-pypy
 def add_player(self, player_id=0, sessionid=""):
     log("Adding player " + player_id)
     socket = self.sessionSocket(sessionid)
     socket.send(message(CMSG_ADD_PLAYER, int(player_id)))
コード例 #7
0
ファイル: bnb.py プロジェクト: TheDunn/flex-pypy
 def player_name(self, player_id=0, name="", sessionid=""):
     log("Changing player #%s name to %s" % (player_id, name))
     socket = self.sessionSocket(sessionid)
     socket.send(message(CMSG_PLAYER_NAME, int(player_id), name))
コード例 #8
0
ファイル: bnb.py プロジェクト: griels/pypy-sc
 def remove_player(self, player_id=0, sessionid=""):
     log("Remove player " + player_id)
     socket = self.sessionSocket(sessionid)
     socket.send(message(CMSG_REMOVE_PLAYER, int(player_id)))
コード例 #9
0
ファイル: bnb.py プロジェクト: griels/pypy-sc
 def add_player(self, player_id=0, sessionid=""):
     log("Adding player " + player_id)
     socket = self.sessionSocket(sessionid)
     socket.send(message(CMSG_ADD_PLAYER, int(player_id)))
コード例 #10
0
ファイル: bnb.py プロジェクト: griels/pypy-sc
 def player_name(self, player_id=0, name="", sessionid=""):
     log("Changing player #%s name to %s" % (player_id, name))
     socket = self.sessionSocket(sessionid)
     socket.send(message(CMSG_PLAYER_NAME, int(player_id), name))