示例#1
0
    def _packetReceived(self, pkt):
        self.resetTimeout()
        try:
            if self.factory.serverConfig.Debug:
                try:
                    username = self._user.profile.name
                except AttributeError:
                    username = ''
                log.debug('[RECV {%s}]: %s' %
                          (username, PacketFormatter.format(pkt)))

            # handle heartbeat packet here, since it's the same
            # across all types of servers
            if pkt.header.id == 0x0005:
                pkt.header.packet_count = self._count
                self.send(pkt)
                return
            # let subclasses handle it
            self.packetReceived(pkt)
        except:
            log.msg("Error in protocol._packetReceived: %s" %
                    sys.exc_info()[0])
            exc_type, exc_value, exc_traceback = sys.exc_info()
            lines = traceback.format_exception(exc_type, exc_value,
                                               exc_traceback)
            log.msg("Lines: %s" % lines)
            log.msg('[RECV {%s}]: %s' %
                    (username, PacketFormatter.format(pkt)))
示例#2
0
 def _packetReceived(self, pkt):
     self.resetTimeout()
     try:
         if self.factory.serverConfig.Debug:
             try:
                 username = self._user.profile.name
             except AttributeError:
                 username = ''            
             log.debug('[RECV {%s}]: %s' % (
                 username, PacketFormatter.format(pkt)))
 
         # handle heartbeat packet here, since it's the same
         # across all types of servers
         if pkt.header.id == 0x0005:
             pkt.header.packet_count = self._count
             self.send(pkt)
             return
         # let subclasses handle it
         self.packetReceived(pkt)
     except:
         log.msg("Error in protocol._packetReceived: %s" % sys.exc_info()[0])
         exc_type, exc_value, exc_traceback = sys.exc_info()
         lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
         log.msg("Lines: %s" % lines)
         log.msg('[RECV {%s}]: %s' % (username, PacketFormatter.format(pkt)))
示例#3
0
 def send(self, pkt):
     #log.msg('sending: %s' % repr(pkt))
     if self.factory.serverConfig.Debug:
         try:
             username = self._user.profile.name
         except AttributeError:
             username = ''
         log.debug('[SEND {%s}]: %s' % (
             username, PacketFormatter.format(pkt)))
     self.transport.write(stream.xorData(str(pkt),0))
     self._count += 1
示例#4
0
 def send(self, pkt):
     #log.msg('sending: %s' % repr(pkt))
     if self.factory.serverConfig.Debug:
         try:
             username = self._user.profile.name
         except AttributeError:
             username = ''
         log.debug('[SEND {%s}]: %s' %
                   (username, PacketFormatter.format(pkt)))
     self.transport.write(stream.xorData(str(pkt), 0))
     self._count += 1
示例#5
0
    def _packetReceived(self, pkt):
        if self.factory.serverConfig.Debug:
            try:
                username = self._user.profile.name
            except AttributeError:
                username = ''
            log.debug('[RECV {%s}]: %s' %
                      (username, PacketFormatter.format(pkt)))

        # handle heartbeat packet here, since it's the same
        # across all types of servers
        if pkt.header.id == 0x0005:
            pkt.header.packet_count = self._count
            self.send(pkt)
            return
        # let subclasses handle it
        self.packetReceived(pkt)
示例#6
0
 def connectionMade(self):
     try:
         self.transport.setTcpKeepAlive(1)
     except:
         log.msg("Error in protocol.connectionMade: %s" % sys.exc_info()[0])
         exc_type, exc_value, exc_traceback = sys.exc_info()
         lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
         log.msg("Lines: %s" % lines)
         log.msg('[RECV {%s}]: %s' % (username, PacketFormatter.format(pkt)))
     try:
         PacketReceiver.connectionMade(self)
         self._handlers = dict()
         self.register()
     except:
         log.msg("Error in protocol.connectionMade: %s" % sys.exc_info()[0])
         exc_type, exc_value, exc_traceback = sys.exc_info()
         lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
         log.msg("Lines: %s" % lines)
示例#7
0
 def connectionMade(self):
     try:
         self.transport.setTcpKeepAlive(1)
     except:
         log.msg("Error in protocol.connectionMade: %s" % sys.exc_info()[0])
         exc_type, exc_value, exc_traceback = sys.exc_info()
         lines = traceback.format_exception(exc_type, exc_value,
                                            exc_traceback)
         log.msg("Lines: %s" % lines)
         log.msg('[RECV {%s}]: %s' %
                 (username, PacketFormatter.format(pkt)))
     try:
         PacketReceiver.connectionMade(self)
         self._handlers = dict()
         self.register()
     except:
         log.msg("Error in protocol.connectionMade: %s" % sys.exc_info()[0])
         exc_type, exc_value, exc_traceback = sys.exc_info()
         lines = traceback.format_exception(exc_type, exc_value,
                                            exc_traceback)
         log.msg("Lines: %s" % lines)