示例#1
0
	def tskDisconnectPolling(self, task):
		while self.cManager.resetConnectionAvailable() == True:
			connPointer = PointerToConnection()
			self.cManager.getResetConnection(connPointer)
			connection = connPointer.p()
			
			# Remove the connection
			self.cReader.removeConnection(connection)
			# Check for if it was a client
			for client in self.activeClients:
				if client.connection == connection:
					print 'removing client'
					self.activeClients.remove(client)
					break
			# then check servers
			for server in self.activeServers:
				if server.connection == connection:
					self.activeServers.remove(server)
					break
			# then check servers
			for chat in self.activeChats:
				if chat.connection == connection:
					self.activeChats.remove(chat)
					break
		
		return Task.cont
示例#2
0
    def tskDisconnectPolling(self, task):
        while self.cManager.resetConnectionAvailable() == True:
            connPointer = PointerToConnection()
            self.cManager.getResetConnection(connPointer)
            connection = connPointer.p()

            # Remove the connection
            self.cReader.removeConnection(connection)
            # Check for if it was a client
            for client in self.activeClients:
                if client.connection == connection:
                    print 'removing client'
                    self.activeClients.remove(client)
                    break
            # then check servers
            for server in self.activeServers:
                if server.connection == connection:
                    self.activeServers.remove(server)
                    break
            # then check servers
            for chat in self.activeChats:
                if chat.connection == connection:
                    self.activeChats.remove(chat)
                    break

        return Task.cont
    def tcpListenerTask(self, task):
        """
        Accept new incoming connection from clients, related to TCP
        """
        # Handle new connection
        if self.connectionManager.tcpListener.newConnectionAvailable():
            rendezvous = PointerToConnection()
            netAddress = NetAddress()
            newConnection = PointerToConnection()

            if self.connectionManager.tcpListener.getNewConnection(
                    rendezvous, netAddress, newConnection):
                newConnection = newConnection.p()
                self.connectionManager.tcpReader.addConnection(newConnection)

                clientId = generateUUID()
                self.connectionManager.streamMgr.clientManager.clients[newConnection] = Client(clientId, \
                                        self.connectionManager.streamMgr.server, newConnection, netAddress)
                print "Server: New Connection from -", str(
                    netAddress.getIpString()), clientId

            else:
                print "Server: Connection Failed from -", str(
                    netAddress.getIpString())

        return Task.cont
示例#4
0
	def tskListenerPolling(self, task):
		if self.cListener.newConnectionAvailable():
			rendezvous = PointerToConnection()
			netAddress = NetAddress()
			newConnection = PointerToConnection()
			if self.cListener.getNewConnection(rendezvous, netAddress, newConnection):
				newConnection = newConnection.p()
				self.tempConnections.append(newConnection)
				self.cReader.addConnection(newConnection)
		return Task.cont
示例#5
0
 def tskListenerPolling(self, task):
     if self.cListener.newConnectionAvailable():
         rendezvous = PointerToConnection()
         netAddress = NetAddress()
         newConnection = PointerToConnection()
         if self.cListener.getNewConnection(rendezvous, netAddress,
                                            newConnection):
             newConnection = newConnection.p()
             self.tempConnections.append(newConnection)
             self.cReader.addConnection(newConnection)
     return Task.cont
示例#6
0
文件: Server.py 项目: czorn/Modifire
 def TCPConnectionListenTask(self, task):
     if self.tcpListener.newConnectionAvailable():
         rendezvous = PointerToConnection()
         netAddress = NetAddress()
         newConnection = PointerToConnection()
     
         if self.tcpListener.getNewConnection(rendezvous, netAddress, newConnection):
             newConnection = newConnection.p()
             self.tcpReader.addConnection(newConnection)
             self.tcpPacketController.AddConnection(newConnection, netAddress)
     return task.cont
示例#7
0
文件: TestTCP.py 项目: czorn/Modifire
 def tskListenerPolling(self, task):
     if self.tcpListener.newConnectionAvailable():
         rendezvous = PointerToConnection()
         netAddress = NetAddress()
         newConnection = PointerToConnection()
     
         if self.tcpListener.getNewConnection(rendezvous, netAddress, newConnection):
             newConnection = newConnection.p()
             self.tcpReader.addConnection(newConnection)
             self.conn = newConnection
             print self.conn.getAddress().getPort()
     return task.cont
示例#8
0
    def tskDisconnectPolling(self, task):
        while self.cManager.resetConnectionAvailable() == True:
            connPointer = PointerToConnection()
            self.cManager.getResetConnection(connPointer)
            connection = connPointer.p()

            # Remove the connection we just found to be "reset" or "disconnected"
            self.cReader.removeConnection(connection)

            # Let us know that we are not connected
            self.connected = False

        return Task.cont
示例#9
0
	def tskDisconnectPolling(self, task):
		while self.cManager.resetConnectionAvailable() == True:
			connPointer = PointerToConnection()
			self.cManager.getResetConnection(connPointer)
			connection = connPointer.p()

			# Remove the connection we just found to be "reset" or "disconnected"
			self.cReader.removeConnection(connection)

			# Let us know that we are not connected
			self.connected = False

		return Task.cont
    def connection_polling(self, taskdata):
        if self.cListener.newConnectionAvailable():
            rendezvous = PointerToConnection()
            netAddress = NetAddress()
            newConn = PointerToConnection()
            if self.cListener.getNewConnection(rendezvous,netAddress, newConn):
                conn = newConn.p()
                self.cReader.addConnection(conn)     # Begin reading connection
                conn_id = self.client_counter
                logging.info("New Connection from ip:%s, conn:%s"
                             % (conn.getAddress(), conn_id))
                self.connection_map[conn_id] = conn
                self.client_counter += 1
                message = eVV_ACK_OK(self.ip, self.port, conn_id)
                self.sendMessage(message, conn)

        return Task.cont
示例#11
0
文件: GameServer.py 项目: crempp/psg
	def __listenTask(self, Task):
		''' This task listens for connections. When a connection is made it
			adds the connection to the clients list and begins listening to
			that connection.'''
		if self._cListener.newConnectionAvailable():
			rendezvous = PointerToConnection()
			netAddress = NetAddress()
			newConnection = PointerToConnection()
			
			if self._cListener.getNewConnection(rendezvous,netAddress,newConnection):
				newConnection = newConnection.p()
				if newConnection not in self.connections:
					self.connections.append(newConnection)
					self._cReader.addConnection(newConnection)     # Begin reading connection
					self._console.printNotice('Connection from %s'%netAddress.getIpString())
				else:
					self._console.printNotice('%s: already connected'%(newConnection.getAddress().getIpString()))
		return Task.cont
    def connection_polling(self, taskdata):
        if self.cListener.newConnectionAvailable():
            rendezvous = PointerToConnection()
            netAddress = NetAddress()
            newConn = PointerToConnection()
            if self.cListener.getNewConnection(rendezvous, netAddress,
                                               newConn):
                conn = newConn.p()
                self.cReader.addConnection(conn)  # Begin reading connection
                conn_id = self.client_counter
                logging.info("New Connection from ip:%s, conn:%s" %
                             (conn.getAddress(), conn_id))
                self.connection_map[conn_id] = conn
                self.client_counter += 1
                message = eVV_ACK_OK(self.ip, self.port, conn_id)
                self.sendMessage(message, conn)

        return Task.cont
示例#13
0
	def tskDisconnectPolling(self, task):
		while self.cManager.resetConnectionAvailable() == True:
			connPointer = PointerToConnection()
			self.cManager.getResetConnection(connPointer)
			connection = connPointer.p()
			
			# Remove the connection we just found to be "reset" or "disconnected"
			self.cReader.removeConnection(connection)
			
			# remove from our activeConnections list
			if connection in self.tempConnections:
				self.tempConnections.remove(connection)
			for user in self.unauthenticatedUsers:
				if connection == user.connection:
					self.unauthenticatedUsers.remove(user)
			for user in self.users:
				if connection == user.connection:
					user.connection = None
					self.passData(('disconnect', user.name), None)
		
		return Task.cont
 def disconnection_polling(self, taskdata):
     if(self.cManager.resetConnectionAvailable()):
         connectionPointer = PointerToConnection()
         self.cManager.getResetConnection(connectionPointer)
         lostConnection = connectionPointer.p()
         for session in self.activeSessions.values():
             if session.conn == lostConnection:
                 logging.info("Lost Connection from ip:%s, conn:%s" 
                              %(session.client_address, session.conn_id))
                 conn_id = session.conn_id
                 if session.getSessionType() == VP:
                     cameras = session.getCameras()
                     for cam_id in cameras:
                         camera = self.cam_mgr.getCameraById(cam_id)
                         camera.clearSession()
                   
                 del self.activeSessions[conn_id]
                 del self.connection_map[conn_id]
                 break
         self.cManager.closeConnection(lostConnection)
     return Task.cont
    def disconnection_polling(self, taskdata):
        if (self.cManager.resetConnectionAvailable()):
            connectionPointer = PointerToConnection()
            self.cManager.getResetConnection(connectionPointer)
            lostConnection = connectionPointer.p()
            for session in self.activeSessions.values():
                if session.conn == lostConnection:
                    logging.info("Lost Connection from ip:%s, conn:%s" %
                                 (session.client_address, session.conn_id))
                    conn_id = session.conn_id
                    if session.getSessionType() == VP:
                        cameras = session.getCameras()
                        for cam_id in cameras:
                            camera = self.cam_mgr.getCameraById(cam_id)
                            camera.clearSession()

                    del self.activeSessions[conn_id]
                    del self.connection_map[conn_id]
                    break
            self.cManager.closeConnection(lostConnection)
        return Task.cont
    def handleDisconnects(self, task):
        """This is just a basic idea, and pretty brutal
        TODO: Maybe get the ip of the connection that did the disconnect along with
        removing any ingame objects belonging to that connection
        """
        # Handle Disconnections

        if self.connectionManager.tcpManager.resetConnectionAvailable():
            clients = self.connectionManager.streamMgr.clientManager.clients
            connection = PointerToConnection()
            if self.connectionManager.tcpManager.getResetConnection(
                    connection):
                connection = connection.p()
                for client in clients:
                    if clients[client].connection == connection:
                        self.connectionManager.tcpManager.closeConnection(
                            clients[client].connection)
                        print clients[client].netAddress.getIpString(
                        ), "Disconnected"
                        del clients[
                            client]  # This will change, should clean out everything first
                        break

        return Task.again
示例#17
0
	def tskListenerPolling(self, task):
		if self.cListener.newConnectionAvailable():
			rendezvous = PointerToConnection()
			netAddress = NetAddress()
			newConnection = PointerToConnection()

			if self.cListener.getNewConnection(rendezvous, netAddress, newConnection):
				newConnection = newConnection.p()
				newConnection.setNoDelay(True)
				self.tempConnections.append(newConnection)	# Remember connection
				self.cReader.addConnection(newConnection)	# Begin reading connection
		return Task.cont