(self,command,response)
return data
打包数据包
打包数据包
打包数据包
def pack(self,command,response):
        '''打包数据包
        '''
        HEAD_0 = chr(self.HEAD_0)
        HEAD_1 = chr(self.HEAD_1)
        HEAD_2 = chr(self.HEAD_2)
        HEAD_3 = chr(self.HEAD_3)
        protoVersion = chr(self.protoVersion)
        serverVersion = self.serverVersion
        length = response.__len__()+4
        commandID = command
        data = struct.pack('!sssss3I',HEAD_0,HEAD_1,HEAD_2,HEAD_3,\
                           protoVersion,serverVersion,length,commandID)
        data = data + response
        return data
def pack ( self , command , response ) : HEAD_0 = chr ( self . HEAD_0 ) HEAD_1 = chr ( self . HEAD_1 ) HEAD_2 = chr ( self . HEAD_2 ) HEAD_3 = chr ( self . HEAD_3 ) protoVersion = chr ( self . protoVersion ) serverVersion = self . serverVersion length = response . __len__ ( ) + 4 commandID = command data = struct . pack ( '!sssss3I' , HEAD_0 , HEAD_1 , HEAD_2 , HEAD_3 , protoVersion , serverVersion , length , commandID ) data = data + response return data