Пример #1
0
    def _disconnect(self, connection):

        address = connection.get_address()
        player = None

        if not address:
            logging.debug("Invalid connection, ignoring")
            return

        logging.debug("Disconnecting connection %s" % connection.get_address())

        try:
            connection.close()
        except IOError:
            pass

        if address in self._players_by_address:
            player = self.get_player_by_address(address)

        with self._connections_lock:
            del self._connections[address]

        if player:
            logging.info("Player %s has quit" % player.name)
            del self._players_by_address[address]
            del self._players[player.player_id]
            self.broadcast(
                DespawnPlayerPacket.make({"player_id": player.player_id}))
            self.broadcast(
                MessagePacket.make({
                    "player_id": 0,
                    "message": "&e%s&f has quit!" % player.name
                }))
Пример #2
0
    def _disconnect(self, connection):

        address = connection.get_address()
        player = None

        if not address:
            logging.debug("Invalid connection, ignoring")
            return

        logging.debug("Disconnecting connection %s" % connection.get_address())

        try:
            connection.close()
        except IOError:
            pass

        if address in self._players_by_address:
            player = self.get_player_by_address(address)

        with self._connections_lock:
            del self._connections[address]

        if player:
            logging.info("Player %s has quit" % player.name)
            del self._players_by_address[address]
            del self._players[player.player_id]
            self.broadcast(DespawnPlayerPacket.make({"player_id": player.player_id}))
            self.broadcast(MessagePacket.make({"player_id": 0, "message": "&e%s&f has quit!" % player.name}))
Пример #3
0
    def _disconnect(self, connection):
        player = None

        if connection.get_address() in self._players_by_address:
            player = self.get_player_by_address(connection.get_address())

        logging.info("DISCONNECT: Acquiring connection lock")
        with self._connections_lock:
            logging.info("DISCONNECT: connection lock acquired")
            del self._connections[connection.get_address()]
        logging.info("DISCONNECT: connection lock released")

        if player:
            logging.info("Player %s has quit" % player.name)
            del self._players_by_address[connection.get_address()]
            del self._players[player.player_id]
            self.broadcast(DespawnPlayerPacket.make({"player_id": player.player_id}))
            self.broadcast(MessagePacket.make({"player_id": 0, "message": "&e%s&f has quit!" % player.name}))