def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: if self.client_protocol is not None: x = build_packet(packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build(Container(data=0))) if self.player is not None and self.player.logged_in: self.client_disconnect_request(x) self.client_protocol.transport.write(x) self.client_protocol.transport.abortConnection() except: logger.error("Couldn't disconnect protocol.") finally: try: self.factory.protocols.pop(self.id) except: logger.info("Protocol was not in factory list. This should not happen.") logger.info("protocol id: %s" % self.id) finally: logger.info("Lost connection from IP: %s", self.transport.getPeer().host) self.transport.abortConnection()
def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: if self.client_protocol is not None: x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build( Container(data=0))) if self.player is not None and self.player.logged_in: self.client_disconnect_request(x) self.client_protocol.transport.write(x) self.client_protocol.transport.abortConnection() except: logger.error("Couldn't disconnect protocol.") finally: try: self.factory.protocols.pop(self.id) except: logger.info( "Protocol was not in factory list. This should not happen." ) logger.info("protocol id: %s" % self.id) finally: logger.info("Lost connection from IP: %s", self.transport.getPeer().host) self.transport.abortConnection()
def disconnect(self): x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build(Container(data=0)) ) self.transport.write(x) self.transport.abortConnection()
def disconnect(self): logger.vdebug('Client protocol disconnect called.') x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build(Container(data=0)) ) self.transport.write(x) self.transport.abortConnection() logger.vdebug('Client protocol disconnected.')
def connectionLost(self, reason=connectionDone): """ Called as a pseudo-destructor when the connection is lost. :param reason: The reason for the disconnection. :return: None """ try: logger.vdebug('Trying to disconnect protocol from factory') if self.client_protocol is not None: logger.vdebug('The client_protocol is not None') x = build_packet( packets.Packets.CLIENT_DISCONNECT_REQUEST, packets.client_disconnect_request().build( Container(data=0) ) ) logger.vdebug('Disconnect packet has been built') try: if self.player is not None and self.player.logged_in: logger.vdebug('Player not none and is still logged in') self.client_disconnect_request(x) logger.vdebug('Client disconnect requested') except: logger.error('Couldn\'t complete disconnect request.') finally: self.client_protocol.transport.write(x) logger.vdebug('Kill packet written to transport protocol') self.client_protocol.transport.abortConnection() logger.vdebug('connection aborted') self.player.logged_in = 0 logger.vdebug('Player status forced to logged_in=0') except: logger.error('Couldn\'t disconnect protocol.') finally: try: self.factory.protocols.pop(self.id) except: logger.warning( 'Protocol was not in factory list. This should not happen.' ) logger.info('protocol id: %s' % self.id) finally: logger.info( 'Lost connection from IP: %s', self.transport.getPeer().host ) logger.vdebug('Connection aborted') self.transport.abortConnection()