Esempio n. 1
0
 def dataReceived(self, data):
     ba = ByteArray(data)
     print ba.bytesAvailable()
     s = ba.readUnsignedInt()
     print ba.bytesAvailable()
     print s
     s = ba.readUTFBytes(ba.bytesAvailable())
     print s
Esempio n. 2
0
 def lineReceived(self, line):
     print line
     ba = ByteArray(line)
     print ba.bytesAvailable()
     s = ba.readInt()
     print s
     s = ba.readUTFBytes(ba.bytesAvailable())
     print s
     self.factory.sendAll(self, line)
Esempio n. 3
0
def read_data(data):
    ba = ByteArray(data)
    #大端模式标准对齐方式
    ba.endian = "!"
    length = ba.readInt()

    print "length", length

    print "bytesAvailable", ba.bytesAvailable()

    #只用了1位字节存储 长度-128 - 127
    #业务大类
    actionName = ba.readByte()
    #具体业务类型
    type = ba.readByte()

    print "actionName", actionName
    print "type", type

    str = ba.readUTFBytes(3)
    print str


    i = ba.readInt()
    print i
Esempio n. 4
0
 def decode(self, data):
     ba = ByteArray(data)
     ba.endian = "!"
     #判断长度
     #print 'self.tempDataBuffer', self.tempDataBuffer
     if self.tempDataBuffer == "":
         self.id = ba.readInt()
         print self.id
         length = ba.readInt()
         s = ba.readUTFBytes(ba.bytesAvailable())
         print 'length', length, len(s)
         #判断长度
         if len(s) < length:
             self.tempDataBuffer = s
         else:
             print "content", s
             return {"id": self.id, "content": s}
     else:
         s = self.tempDataBuffer + ba.readUTFBytes(ba.bytesAvailable())
         print 'hebing', s
         return {"id": self.id, "content": s}
Esempio n. 5
0
 def decode(self, data):
     ba = ByteArray(data)
     ba.endian = "!"
     #判断长度
     #print 'self.tempDataBuffer', self.tempDataBuffer
     if self.tempDataBuffer == "":
         self.id = ba.readInt()
         print self.id
         length = ba.readInt()
         s = ba.readUTFBytes(ba.bytesAvailable())
         print 'length', length, len(s)
         #判断长度
         if len(s) < length:
             self.tempDataBuffer = s
         else:
             print "content", s
             return {"id":self.id, "content":s}
     else:
         s = self.tempDataBuffer + ba.readUTFBytes(ba.bytesAvailable())
         print 'hebing', s
         return {"id":self.id, "content":s}
Esempio n. 6
0
def read_data(data):
    ba = ByteArray(data)
    #大端模式标准对齐方式
    ba.endian = "!"
    length = ba.readInt()

    print "length", length

    print "bytesAvailable", ba.bytesAvailable()

    #只用了1位字节存储 长度-128 - 127
    #业务大类
    actionName = ba.readByte()
    #具体业务类型
    type = ba.readByte()

    print "actionName", actionName
    print "type", type

    str = ba.readUTFBytes(3)
    print str

    i = ba.readInt()
    print i