Ejemplo n.º 1
0
 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]
Ejemplo n.º 2
0
 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]
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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)))
Ejemplo n.º 6
0
 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)))
Ejemplo n.º 7
0
 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))
Ejemplo n.º 8
0
 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)))
Ejemplo n.º 9
0
 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)))
Ejemplo n.º 10
0
 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))