mirror of
https://port.numenaute.org/aleajactaest/clientbot.git
synced 2024-11-09 08:49:05 +00:00
adding more detail to debug message received
This commit is contained in:
parent
aa291fdb92
commit
00364990cb
1 changed files with 239 additions and 166 deletions
403
client.py
403
client.py
|
@ -175,24 +175,26 @@ class BitStream():
|
||||||
if need != 8:
|
if need != 8:
|
||||||
self.internalSerial(source.readSerial(need), need)
|
self.internalSerial(source.readSerial(need), need)
|
||||||
while source.needRead() >= 8:
|
while source.needRead() >= 8:
|
||||||
self.pushUint8(source.readUint8())
|
self.pushUint8(source.readSerial(8, False))
|
||||||
|
|
||||||
need = source.needRead()
|
need = source.needRead()
|
||||||
if need > 0:
|
if need > 0:
|
||||||
self.internalSerial(source.readSerial(need), need)
|
self.internalSerial(source.readSerial(need, False), need)
|
||||||
|
|
||||||
source.putRead(srcRead)
|
source.putRead(srcRead)
|
||||||
|
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
def readSerial(self, nbits, decode=True):
|
def readSerial(self, nbits, name="", decode=True, typeName='', emulate=False):
|
||||||
if nbits == 0:
|
if nbits == 0:
|
||||||
return
|
return
|
||||||
elif nbits > 32:
|
elif nbits > 32:
|
||||||
raise "Out of range"
|
raise "Out of range"
|
||||||
if self._read + nbits > self._pos:
|
if self._read + nbits > self._pos:
|
||||||
raise "Stream Overflow"
|
raise "Stream Overflow"
|
||||||
if decode:
|
if decode and not emulate:
|
||||||
self._groupRead.append((self._read, self._read+nbits))
|
self._groupRead.append((self._read, self._read+nbits, name, typeName))
|
||||||
|
if emulate:
|
||||||
|
oldRead = self._read
|
||||||
value = 0
|
value = 0
|
||||||
pos = self._read // 8
|
pos = self._read // 8
|
||||||
_FreeBits = 8 - (self._read % 8)
|
_FreeBits = 8 - (self._read % 8)
|
||||||
|
@ -200,93 +202,109 @@ class BitStream():
|
||||||
if nbits > _FreeBits:
|
if nbits > _FreeBits:
|
||||||
value |= (v << (nbits-_FreeBits))
|
value |= (v << (nbits-_FreeBits))
|
||||||
self._read += _FreeBits
|
self._read += _FreeBits
|
||||||
value |= self.readSerial(nbits - _FreeBits, False)
|
value |= self.readSerial(nbits - _FreeBits, decode=False)
|
||||||
else:
|
else:
|
||||||
value |= (v >> (_FreeBits-nbits))
|
value |= (v >> (_FreeBits-nbits))
|
||||||
self._read += nbits
|
self._read += nbits
|
||||||
|
if emulate:
|
||||||
|
self._read = oldRead
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def readBool(self):
|
def readBool(self, name):
|
||||||
v = self.readSerial(1)
|
v = self.readSerial(1, name=name, typeName='Bool')
|
||||||
if v != 0:
|
if v != 0:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def readUint32(self):
|
def readUint32(self, name, decode=True, typeName='Uint32'):
|
||||||
v = self.readSerial(32)
|
v = self.readSerial(32, name=name, decode=decode, typeName=typeName)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def readSint32(self):
|
def readSint32(self, name):
|
||||||
v = self.readSerial(32)
|
v = self.readSerial(32, name=name, typeName='Sint32')
|
||||||
return c_int32(v).value
|
return c_int32(v).value
|
||||||
|
|
||||||
def readUint16(self):
|
def readUint16(self, name):
|
||||||
v = self.readSerial(16)
|
v = self.readSerial(16, name=name, typeName='Uint16')
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def readSint16(self):
|
def readSint16(self, name):
|
||||||
v = self.readSerial(16)
|
v = self.readSerial(16, name=name, typeName='Sint16')
|
||||||
return c_int16(v).value
|
return c_int16(v).value
|
||||||
|
|
||||||
def readUint8(self):
|
def readUint8(self, name, decode=True, typeName='Uint8'):
|
||||||
v = self.readSerial(8)
|
v = self.readSerial(8, decode=decode, name=name, typeName=typeName)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def readSint8(self):
|
def readSint8(self, name):
|
||||||
v = self.readSerial(8)
|
v = self.readSerial(8, name=name, typeName='Sint8')
|
||||||
return c_int8(v).value
|
return c_int8(v).value
|
||||||
|
|
||||||
def readUint64(self):
|
def readUint64(self, name):
|
||||||
v = self.readSerial(32)
|
self._groupRead.append((self._read, self._read+64, name, 'Uint64'))
|
||||||
v1 = self.readSerial(32)
|
v = self.readSerial(32, decode=False)
|
||||||
|
v1 = self.readSerial(32, decode=False)
|
||||||
v2 = v | (v1 << 32)
|
v2 = v | (v1 << 32)
|
||||||
return v2
|
return v2
|
||||||
|
|
||||||
def readSint64(self):
|
def readSint64(self, name):
|
||||||
v = self.readSerial(32)
|
self._groupRead.append((self._read, self._read+64, name, 'Sint64'))
|
||||||
v1 = self.readSerial(32)
|
v = self.readSerial(32, decode=False)
|
||||||
|
v1 = self.readSerial(32, decode=False)
|
||||||
v2 = v | (v1 << 32)
|
v2 = v | (v1 << 32)
|
||||||
return c_int64(v2).value
|
return c_int64(v2).value
|
||||||
|
|
||||||
def readFloat(self):
|
def readFloat(self, name):
|
||||||
v = self.readSerial(32)
|
v = self.readSerial(32, name=name, typeName='Float')
|
||||||
v1 = struct.pack('I', v)
|
v1 = struct.pack('I', v)
|
||||||
v2 = struct.unpack('<f',v1)[0]
|
v2 = struct.unpack('<f',v1)[0]
|
||||||
return v2
|
return v2
|
||||||
|
|
||||||
def readDouble(self):
|
def readDouble(self, name):
|
||||||
v = self.readSerial(32)
|
self._groupRead.append((self._read, self._read+64, name, 'Double'))
|
||||||
|
v = self.readSerial(32, decode=False)
|
||||||
v1 = struct.pack('I', v)
|
v1 = struct.pack('I', v)
|
||||||
w = self.readSerial(32)
|
w = self.readSerial(32, decode=False)
|
||||||
w1 = struct.pack('I', w)
|
w1 = struct.pack('I', w)
|
||||||
x = v1 + w1
|
x = v1 + w1
|
||||||
x1 = struct.unpack('<d', x)[0]
|
x1 = struct.unpack('<d', x)[0]
|
||||||
return x1
|
return x1
|
||||||
|
|
||||||
def readChar(self):
|
def readChar(self, name, decode=True):
|
||||||
v = self.readUint8()
|
v = self.readUint8(name=name, decode=decode, typeName='Char')
|
||||||
return chr(v)
|
return chr(v)
|
||||||
|
|
||||||
def readString(self):
|
def readString(self, name):
|
||||||
tmp = ''
|
tmp = ''
|
||||||
_size = self.readUint32()
|
v1 = self._read
|
||||||
|
_size = self.readUint32('', decode=False)
|
||||||
while _size > 0:
|
while _size > 0:
|
||||||
x = self.readChar()
|
x = self.readChar('', decode=False)
|
||||||
tmp += x
|
tmp += x
|
||||||
_size -= 1
|
_size -= 1
|
||||||
|
v2 = self._read
|
||||||
|
if v2 > self._pos:
|
||||||
|
raise ValueError
|
||||||
|
self._groupRead.append((v1, v2, name, 'String'))
|
||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
def readArrayUint8(self, size):
|
def readArrayUint8(self, size, name):
|
||||||
ret = []
|
ret = []
|
||||||
|
v1 = self._read
|
||||||
for i in range(0, size):
|
for i in range(0, size):
|
||||||
ret.append(self.readUint8())
|
ret.append(self.readUint8('', decode=False))
|
||||||
|
v2 = self._read
|
||||||
|
self._groupRead.append((v1, v2, name, 'ArrayUint8'))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def readBitStreamUint8(self, size):
|
def readBitStreamUint8(self, size, name):
|
||||||
ret = BitStream()
|
ret = BitStream()
|
||||||
|
v1 = self._read
|
||||||
for i in range(0, size):
|
for i in range(0, size):
|
||||||
ret.pushUint8(self.readUint8())
|
ret.pushUint8(self.readUint8('', decode=False))
|
||||||
|
v2 = self._read
|
||||||
|
self._groupRead.append((v1, v2, name, 'StreamUint8'))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
# ------------------------------------
|
# ------------------------------------
|
||||||
|
@ -310,12 +328,28 @@ class BitStream():
|
||||||
readBefore = self._read
|
readBefore = self._read
|
||||||
while self._read < self._pos:
|
while self._read < self._pos:
|
||||||
if self._pos - self._read >= 8:
|
if self._pos - self._read >= 8:
|
||||||
data = self.readUint8()
|
nsize = 8
|
||||||
else:
|
else:
|
||||||
data = self.readSerial(self._pos - self._read)
|
nsize = self._pos - self._read
|
||||||
|
data = self.readSerial(nsize, decode=False)
|
||||||
|
if nsize == 1:
|
||||||
|
ret += "{0:01b}".format(data)
|
||||||
|
elif nsize == 2:
|
||||||
|
ret += "{0:02b}".format(data)
|
||||||
|
elif nsize == 3:
|
||||||
|
ret += "{0:03b}".format(data)
|
||||||
|
elif nsize == 4:
|
||||||
|
ret += "{0:04b}".format(data)
|
||||||
|
elif nsize == 5:
|
||||||
|
ret += "{0:05b}".format(data)
|
||||||
|
elif nsize == 6:
|
||||||
|
ret += "{0:06b}".format(data)
|
||||||
|
elif nsize == 7:
|
||||||
|
ret += "{0:07b}".format(data)
|
||||||
|
else:
|
||||||
|
ret += "{0:08b}".format(data)
|
||||||
if ret != "":
|
if ret != "":
|
||||||
ret += "."
|
ret += "."
|
||||||
#ret += hex(data)
|
|
||||||
ret += "{0:08b}".format(data)
|
ret += "{0:08b}".format(data)
|
||||||
self._read = readBefore
|
self._read = readBefore
|
||||||
return ret
|
return ret
|
||||||
|
@ -326,36 +360,66 @@ class BitStream():
|
||||||
self._read = 0
|
self._read = 0
|
||||||
while self._read < self._pos:
|
while self._read < self._pos:
|
||||||
if self._pos - self._read >= 8:
|
if self._pos - self._read >= 8:
|
||||||
data = self.readSerial(8, False)
|
nsize = 8
|
||||||
|
else:
|
||||||
|
nsize = self._pos - self._read
|
||||||
|
data = self.readSerial(nsize, decode=False)
|
||||||
|
if nsize == 1:
|
||||||
|
ret += "{0:01b}".format(data)
|
||||||
|
elif nsize == 2:
|
||||||
|
ret += "{0:02b}".format(data)
|
||||||
|
elif nsize == 3:
|
||||||
|
ret += "{0:03b}".format(data)
|
||||||
|
elif nsize == 4:
|
||||||
|
ret += "{0:04b}".format(data)
|
||||||
|
elif nsize == 5:
|
||||||
|
ret += "{0:05b}".format(data)
|
||||||
|
elif nsize == 6:
|
||||||
|
ret += "{0:06b}".format(data)
|
||||||
|
elif nsize == 7:
|
||||||
|
ret += "{0:07b}".format(data)
|
||||||
else:
|
else:
|
||||||
data = self.readSerial(self._pos - self._read, False)
|
|
||||||
ret += "{0:08b}".format(data)
|
ret += "{0:08b}".format(data)
|
||||||
self._read = readBefore
|
self._read = readBefore
|
||||||
ret2 = ""
|
ret2 = ""
|
||||||
|
|
||||||
last = 0
|
last = 0
|
||||||
for x, y in self._groupRead:
|
for x, y, name, typeName in self._groupRead:
|
||||||
ret2 += "[" + ret[x:y] + "]"
|
ret2 += "[<" + str(x) + ':' + str(y-1) + "> " + str(name) + ' (' + typeName + ') = ' + ret[x:y] + "]"
|
||||||
last = y
|
last = y
|
||||||
if last < self._pos:
|
if last < self._pos:
|
||||||
ret2 += "{" + ret[last:] + "}"
|
ret2 += "{" + ret[last:] + "}"
|
||||||
|
|
||||||
return ret2
|
return ret2
|
||||||
def showAllDataBis(self):
|
def showAllDataRaw(self):
|
||||||
ret = ""
|
ret = ""
|
||||||
readBefore = self._read
|
readBefore = self._read
|
||||||
self._read = 0
|
self._read = 0
|
||||||
while self._read < self._pos:
|
while self._read < self._pos:
|
||||||
if self._pos - self._read >= 8:
|
if self._pos - self._read >= 8:
|
||||||
data = self.readUint8()
|
nsize = 8
|
||||||
else:
|
else:
|
||||||
data = self.readSerial(self._pos - self._read)
|
nsize = self._pos - self._read
|
||||||
|
data = self.readSerial(nsize, decode=False)
|
||||||
|
if nsize == 1:
|
||||||
|
ret += "{0:01b}".format(data)
|
||||||
|
elif nsize == 2:
|
||||||
|
ret += "{0:02b}".format(data)
|
||||||
|
elif nsize == 3:
|
||||||
|
ret += "{0:03b}".format(data)
|
||||||
|
elif nsize == 4:
|
||||||
|
ret += "{0:04b}".format(data)
|
||||||
|
elif nsize == 5:
|
||||||
|
ret += "{0:05b}".format(data)
|
||||||
|
elif nsize == 6:
|
||||||
|
ret += "{0:06b}".format(data)
|
||||||
|
elif nsize == 7:
|
||||||
|
ret += "{0:07b}".format(data)
|
||||||
|
else:
|
||||||
|
ret += "{0:08b}".format(data)
|
||||||
if ret != "":
|
if ret != "":
|
||||||
ret += "."
|
ret += "."
|
||||||
#ret += hex(data)
|
|
||||||
ret += "{0:08b}".format(data)
|
|
||||||
self._read = readBefore
|
self._read = readBefore
|
||||||
ret += ' ' + '.'.join([ str(x) + ':' + str(y) for x, y in self._groupRead] )
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def TestBitStream():
|
def TestBitStream():
|
||||||
|
@ -376,87 +440,104 @@ def TestBitStream():
|
||||||
a.pushSint64(-1)
|
a.pushSint64(-1)
|
||||||
a.pushChar('a')
|
a.pushChar('a')
|
||||||
a.pushString("Test A Faire")
|
a.pushString("Test A Faire")
|
||||||
print('raw:', a)
|
print('raw:')
|
||||||
|
print(a.showAllDataRaw())
|
||||||
|
print("-" * 20)
|
||||||
print("-" * 80)
|
print("-" * 80)
|
||||||
print(a.readBool())
|
print(a.readBool('a1'))
|
||||||
print(a.readBool())
|
print(a.readBool('a2'))
|
||||||
print(a.readBool())
|
print(a.readBool('a3'))
|
||||||
print(a.readBool())
|
print(a.readBool('a4'))
|
||||||
print(a.readUint32())
|
print(a.readUint32('a5'))
|
||||||
print(a.readSint32())
|
print(a.readSint32('a6'))
|
||||||
print(a.readUint16())
|
print(a.readUint16('a7'))
|
||||||
print(a.readSint16())
|
print(a.readSint16('a8'))
|
||||||
print(a.readUint8())
|
print(a.readUint8('a9'))
|
||||||
print(a.readSint8())
|
print(a.readSint8('a10'))
|
||||||
print(a.readFloat())
|
print(a.readFloat('a11'))
|
||||||
print(a.readDouble())
|
print(a.readDouble('a12'))
|
||||||
print(a.readUint64())
|
print(a.readUint64('a13'))
|
||||||
print(a.readSint64())
|
print(a.readSint64('a14'))
|
||||||
print(a.readChar())
|
print(a.readChar('a15'))
|
||||||
print(a.readString())
|
print(a.readString('a16'))
|
||||||
print(a.toBytes())
|
print(a.toBytes())
|
||||||
|
print("-" * 40)
|
||||||
|
print(a.showAllData())
|
||||||
print("-" * 80)
|
print("-" * 80)
|
||||||
b = BitStream()
|
b = BitStream()
|
||||||
b.fromBytes(a.toBytes())
|
b.fromBytes(a.toBytes())
|
||||||
print(b.readBool())
|
print(b.readBool('b1'))
|
||||||
print(b.readBool())
|
print(b.readBool('b2'))
|
||||||
print(b.readBool())
|
print(b.readBool('b3'))
|
||||||
print(b.readBool())
|
print(b.readBool('b4'))
|
||||||
print(b.readUint32())
|
print(b.readUint32('b5'))
|
||||||
print(b.readSint32())
|
print(b.readSint32('b6'))
|
||||||
print(b.readUint16())
|
print(b.readUint16('b7'))
|
||||||
print(b.readSint16())
|
print(b.readSint16('b8'))
|
||||||
print(b.readUint8())
|
print(b.readUint8('b9'))
|
||||||
print(b.readSint8())
|
print(b.readSint8('b10'))
|
||||||
print(b.readFloat())
|
print(b.readFloat('b11'))
|
||||||
print(b.readDouble())
|
print(b.readDouble('b12'))
|
||||||
print(b.readUint64())
|
print(b.readUint64('b13'))
|
||||||
print(b.readSint64())
|
print(b.readSint64('b14'))
|
||||||
print(b.readChar())
|
print(b.readChar('b15'))
|
||||||
print(b.readString())
|
print(b.readString('b16'))
|
||||||
print(b.toBytes())
|
print(b.toBytes())
|
||||||
|
print("-" * 40)
|
||||||
|
print(b.showAllData())
|
||||||
print("-" * 80)
|
print("-" * 80)
|
||||||
c = BitStream()
|
c = BitStream()
|
||||||
c.pushBool(True)
|
c.pushBool(True)
|
||||||
c.pushBitStream(a)
|
c.pushBitStream(a)
|
||||||
c.pushBitStream(b)
|
c.pushBitStream(b)
|
||||||
print(c.readBool())
|
print(c.readBool('c1'))
|
||||||
print("-" * 80)
|
print("-" * 80)
|
||||||
print(c.readBool())
|
print(c.readBool('c2'))
|
||||||
print(c.readBool())
|
print(c.readBool('c3'))
|
||||||
print(c.readBool())
|
print(c.readBool('c4'))
|
||||||
print(c.readBool())
|
print(c.readBool('c5'))
|
||||||
print(c.readUint32())
|
print(c.readUint32('c6'))
|
||||||
print(c.readSint32())
|
print(c.readSint32('c7'))
|
||||||
print(c.readUint16())
|
print(c.readUint16('c8'))
|
||||||
print(c.readSint16())
|
print(c.readSint16('c9'))
|
||||||
print(c.readUint8())
|
print(c.readUint8('c10'))
|
||||||
print(c.readSint8())
|
print(c.readSint8('c11'))
|
||||||
print(c.readFloat())
|
print(c.readFloat('c12'))
|
||||||
print(c.readDouble())
|
print(c.readDouble('c13'))
|
||||||
print(c.readUint64())
|
print(c.readUint64('c14'))
|
||||||
print(c.readSint64())
|
print(c.readSint64('c15'))
|
||||||
print(c.readChar())
|
print(c.readChar('c16'))
|
||||||
print(c.readString())
|
print(c.readString('c17'))
|
||||||
print(c.toBytes())
|
print(c.toBytes())
|
||||||
|
print("-" * 50)
|
||||||
|
print(c.showAllData())
|
||||||
|
print("-" * 50)
|
||||||
|
print(c.readBool('c18'))
|
||||||
|
print(c.readBool('c19'))
|
||||||
|
print(c.readBool('c20'))
|
||||||
|
print(c.readBool('c21'))
|
||||||
|
print(c.readUint32('c22'))
|
||||||
|
print(c.readSint32('c23'))
|
||||||
|
print(c.readUint16('c24'))
|
||||||
|
print(c.readSint16('c25'))
|
||||||
|
print(c.readUint8('c26'))
|
||||||
|
print(c.readSint8('c27'))
|
||||||
|
print(c.readFloat('c28'))
|
||||||
|
print(c.readDouble('c29'))
|
||||||
|
print(c.readUint64('c30'))
|
||||||
|
print(c.readSint64('c31'))
|
||||||
|
print(c.readChar('c32'))
|
||||||
|
print("-" * 40)
|
||||||
|
print(c.showAllData())
|
||||||
|
print(c.readString('c33'))
|
||||||
|
print("-" * 40)
|
||||||
|
print(c.showAllData())
|
||||||
|
print(c.toBytes())
|
||||||
|
print("-" * 40)
|
||||||
|
print(c.showAllDataRaw())
|
||||||
|
print("-" * 20)
|
||||||
|
print(c.showAllData())
|
||||||
print("-" * 80)
|
print("-" * 80)
|
||||||
print(c.readBool())
|
|
||||||
print(c.readBool())
|
|
||||||
print(c.readBool())
|
|
||||||
print(c.readBool())
|
|
||||||
print(c.readUint32())
|
|
||||||
print(c.readSint32())
|
|
||||||
print(c.readUint16())
|
|
||||||
print(c.readSint16())
|
|
||||||
print(c.readUint8())
|
|
||||||
print(c.readSint8())
|
|
||||||
print(c.readFloat())
|
|
||||||
print(c.readDouble())
|
|
||||||
print(c.readUint64())
|
|
||||||
print(c.readSint64())
|
|
||||||
print(c.readChar())
|
|
||||||
print(c.readString())
|
|
||||||
print(c.toBytes())
|
|
||||||
|
|
||||||
NL_BITLEN = 32
|
NL_BITLEN = 32
|
||||||
class CBitSet:
|
class CBitSet:
|
||||||
|
@ -1890,7 +1971,7 @@ class DecodeImpulse():
|
||||||
def impulseStringResp(self, msgin):
|
def impulseStringResp(self, msgin):
|
||||||
self.log.debug("TODO")
|
self.log.debug("TODO")
|
||||||
def impulseReloadCache(self, msgin):
|
def impulseReloadCache(self, msgin):
|
||||||
self.world.timestamp = msgin.readUint32()
|
self.world.timestamp = msgin.readUint32('timestamp')
|
||||||
self.log.debug("Reload Cache timestamp:%d" % self.world.timestamp)
|
self.log.debug("Reload Cache timestamp:%d" % self.world.timestamp)
|
||||||
self.log.debug("Message not read (%d) %s" % (msgin.needRead(), msgin.showLastData() ))
|
self.log.debug("Message not read (%d) %s" % (msgin.needRead(), msgin.showLastData() ))
|
||||||
|
|
||||||
|
@ -2206,17 +2287,19 @@ class DecodeImpulse():
|
||||||
listpath = []
|
listpath = []
|
||||||
while True:
|
while True:
|
||||||
nbBit = getPowerOf2(len(head))
|
nbBit = getPowerOf2(len(head))
|
||||||
#self.log.debug('nbBit:%d' % nbBit)
|
# def readSerial(self, nbits, name="", decode=True, typeName='', emulate=False):
|
||||||
id = msgin.readSerial(nbBit)
|
id = msgin.readSerial(nbBit, name='Ptr', typeName='Number', emulate=True)
|
||||||
#self.log.debug('id:%s' % str(id))
|
|
||||||
ele = head[id]
|
ele = head[id]
|
||||||
name = ele.attrib['name']
|
name = ele.attrib['name']
|
||||||
#self.log.debug(name)
|
|
||||||
listpath.append(name)
|
listpath.append(name)
|
||||||
fullname = ':'.join(listpath)
|
fullname = ':'.join(listpath)
|
||||||
|
|
||||||
|
id = msgin.readSerial(nbBit, name='Ptr', typeName='MsgXML<' + name + '>')
|
||||||
if fullname in self.GenericMsgHeaderMngr:
|
if fullname in self.GenericMsgHeaderMngr:
|
||||||
self.log.debug("Found : %s" % fullname)
|
self.log.debug("Found : %s" % fullname)
|
||||||
self.GenericMsgHeaderMngr[fullname](msgin)
|
self.GenericMsgHeaderMngr[fullname](msgin)
|
||||||
|
self.log.debug("MessageXML decoded: %s" % msgin.showAllData() )
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
#self.log.debug("Non trouve")
|
#self.log.debug("Non trouve")
|
||||||
|
@ -2226,24 +2309,13 @@ class DecodeImpulse():
|
||||||
break
|
break
|
||||||
if head != ele:
|
if head != ele:
|
||||||
self.log.error("Impossible to found %s" % fullname )
|
self.log.error("Impossible to found %s" % fullname )
|
||||||
|
self.log.debug("MessageXML decoded: %s" % msgin.showAllData() )
|
||||||
return False
|
return False
|
||||||
|
self.log.debug("MessageXML decoded: %s" % msgin.showAllData() )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def loadMsg(self, msgXml):
|
def loadMsg(self, msgXml):
|
||||||
self.msgXml = msgXml
|
self.msgXml = msgXml
|
||||||
# print('-'*80)
|
|
||||||
# print(self.msgXml)
|
|
||||||
# print(dir(self.msgXml))
|
|
||||||
# print('-'*80)
|
|
||||||
# print(self.sizeElement())
|
|
||||||
# print(self.sizeElement('STRING'))
|
|
||||||
# print('-'*20)
|
|
||||||
# print(self.searchElement("DB_UPD_PLR"))
|
|
||||||
# print(self.searchElement("STRING:TELL"))
|
|
||||||
# print('-'*80)
|
|
||||||
# self.GenericMsgHeaderMngr['DB_UPD_PLR']('test')
|
|
||||||
# print('-'*80)
|
|
||||||
|
|
||||||
def loadDatabase(self, databaseXml):
|
def loadDatabase(self, databaseXml):
|
||||||
self.databaseXml = databaseXml
|
self.databaseXml = databaseXml
|
||||||
|
@ -2352,8 +2424,8 @@ class CActionGeneric(CAction):
|
||||||
self._Message = None
|
self._Message = None
|
||||||
|
|
||||||
def unpack(self, message):
|
def unpack(self, message):
|
||||||
size = message.readUint32()
|
size = message.readUint32('size')
|
||||||
self._Message = message.readBitStreamUint8(size)
|
self._Message = message.readBitStreamUint8(size, 'message')
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self._Message = None
|
self._Message = None
|
||||||
|
@ -2376,12 +2448,12 @@ class CActionGenericMultiPart(CAction):
|
||||||
self.NbBlock = 0
|
self.NbBlock = 0
|
||||||
|
|
||||||
def unpack(self, message):
|
def unpack(self, message):
|
||||||
self.Number = message.readUint8()
|
self.Number = message.readUint8('Number')
|
||||||
self.Part = message.readUint16()
|
self.Part = message.readUint16('Part')
|
||||||
self.NbBlock = message.readUint16()
|
self.NbBlock = message.readUint16('NbBlock')
|
||||||
|
|
||||||
size = message.readUint32()
|
size = message.readUint32('size')
|
||||||
self.PartCont = message.readBitStreamUint8(size)
|
self.PartCont = message.readBitStreamUint8(size, 'PartCont')
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.PartCont = []
|
self.PartCont = []
|
||||||
|
@ -2483,11 +2555,11 @@ class CActionFactory:
|
||||||
khanat-opennel-code/code/ryzom/common/src/game_share/action_factory.cpp : CAction *CActionFactory::unpack (NLMISC::CBitMemStream &message, NLMISC::TGameCycle /* currentCycle */ )
|
khanat-opennel-code/code/ryzom/common/src/game_share/action_factory.cpp : CAction *CActionFactory::unpack (NLMISC::CBitMemStream &message, NLMISC::TGameCycle /* currentCycle */ )
|
||||||
'''
|
'''
|
||||||
if msgin.needRead() >= 8:
|
if msgin.needRead() >= 8:
|
||||||
shortcode = msgin.readBool()
|
shortcode = msgin.readBool('shortcode')
|
||||||
if shortcode:
|
if shortcode:
|
||||||
code = msgin.readSerial(2)
|
code = msgin.readSerial(2, 'code')
|
||||||
else:
|
else:
|
||||||
code = msgin.readUint8()
|
code = msgin.readUint8('code')
|
||||||
action = self.create(INVALID_SLOT, code)
|
action = self.create(INVALID_SLOT, code)
|
||||||
if action:
|
if action:
|
||||||
try:
|
try:
|
||||||
|
@ -2533,7 +2605,7 @@ class CImpulseDecoder:
|
||||||
self.log.debug("channel:%d lAck:%s" %(channel, ':'.join([str(x) for x in lAck])))
|
self.log.debug("channel:%d lAck:%s" %(channel, ':'.join([str(x) for x in lAck])))
|
||||||
# lastAck = lAck[channel]
|
# lastAck = lAck[channel]
|
||||||
while True:
|
while True:
|
||||||
next = msgin.readBool()
|
next = msgin.readBool('next:' + str(level) + ':' + str(channel))
|
||||||
if not next:
|
if not next:
|
||||||
break
|
break
|
||||||
if not checkOnce:
|
if not checkOnce:
|
||||||
|
@ -2710,8 +2782,9 @@ class ClientNetworkConnection:
|
||||||
self._sock.sendto(msgout.toBytes(), self.frontend)
|
self._sock.sendto(msgout.toBytes(), self.frontend)
|
||||||
|
|
||||||
def readDelta(self, msg):
|
def readDelta(self, msg):
|
||||||
propertyCount = msg.readUint16()
|
propertyCount = msg.readUint16('propertyCount')
|
||||||
self.log.debug("propertyCount:%d" % propertyCount)
|
self.log.debug("propertyCount:%d" % propertyCount)
|
||||||
|
self.log.debug("TODO")
|
||||||
for _ in range(0, propertyCount):
|
for _ in range(0, propertyCount):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -2723,8 +2796,8 @@ class ClientNetworkConnection:
|
||||||
def decodeHeader(self, msg):
|
def decodeHeader(self, msg):
|
||||||
self._TotalMessages += 1
|
self._TotalMessages += 1
|
||||||
self._LastReceivedTime = self._UpdateTime
|
self._LastReceivedTime = self._UpdateTime
|
||||||
self._CurrentReceivedNumber = msg.readSint32()
|
self._CurrentReceivedNumber = msg.readSint32('CurrentReceivedNumber')
|
||||||
self._SystemMode = msg.readBool()
|
self._SystemMode = msg.readBool('SystemMode')
|
||||||
|
|
||||||
if self.checkMessageNumber and self._CurrentReceivedNumber > self._LastReceivedPacketInBothModes:
|
if self.checkMessageNumber and self._CurrentReceivedNumber > self._LastReceivedPacketInBothModes:
|
||||||
self._TotalLostPackets += self._CurrentReceivedNumber - self._LastReceivedPacketInBothModes - 1
|
self._TotalLostPackets += self._CurrentReceivedNumber - self._LastReceivedPacketInBothModes - 1
|
||||||
|
@ -2733,7 +2806,7 @@ class ClientNetworkConnection:
|
||||||
# self._LastReceivedPacketInBothModes = self._CurrentReceivedNumber - 1
|
# self._LastReceivedPacketInBothModes = self._CurrentReceivedNumber - 1
|
||||||
|
|
||||||
if not self._SystemMode:
|
if not self._SystemMode:
|
||||||
self._LastReceivedAck = msg.readSint32();
|
self._LastReceivedAck = msg.readSint32('LastReceivedAck');
|
||||||
self.log.debug("Normal Mode _LastReceivedAck:%d" % self._LastReceivedAck)
|
self.log.debug("Normal Mode _LastReceivedAck:%d" % self._LastReceivedAck)
|
||||||
else:
|
else:
|
||||||
self.log.debug("System Mode")
|
self.log.debug("System Mode")
|
||||||
|
@ -2771,7 +2844,7 @@ class ClientNetworkConnection:
|
||||||
|
|
||||||
def receiveSystemProbe(self, msg):
|
def receiveSystemProbe(self, msg):
|
||||||
self._LatestProbeTime = self._UpdateTime
|
self._LatestProbeTime = self._UpdateTime
|
||||||
self._LatestProbe = msg.readSint32()
|
self._LatestProbe = msg.readSint32('LatestProbe')
|
||||||
self.log.debug("LatestProbe: %d" % self._LatestProbe)
|
self.log.debug("LatestProbe: %d" % self._LatestProbe)
|
||||||
self._LatestProbes.append(self._LatestProbe)
|
self._LatestProbes.append(self._LatestProbe)
|
||||||
|
|
||||||
|
@ -2780,13 +2853,13 @@ class ClientNetworkConnection:
|
||||||
|
|
||||||
def receiveSystemSync(self, msg):
|
def receiveSystemSync(self, msg):
|
||||||
self._LatestSyncTime = self._UpdateTime
|
self._LatestSyncTime = self._UpdateTime
|
||||||
self._Synchronize = msg.readUint32()
|
self._Synchronize = msg.readUint32('Synchronize')
|
||||||
stime = msg.readSint64()
|
stime = msg.readSint64('stime')
|
||||||
self._LatestSync = msg.readUint32()
|
self._LatestSync = msg.readUint32('LatestSync')
|
||||||
self.log.debug("%d %d %d" %(self._Synchronize, stime, self._LatestSync))
|
self.log.debug("%d %d %d" %(self._Synchronize, stime, self._LatestSync))
|
||||||
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp : void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin)
|
# khanat-opennel-code/code/ryzom/client/src/network_connection.cpp : void CNetworkConnection::receiveSystemSync(CBitMemStream &msgin)
|
||||||
MsgData = msg.readArrayUint8(16)
|
MsgData = msg.readArrayUint8(16, 'MsgData')
|
||||||
DatabaseData = msg.readArrayUint8(16)
|
DatabaseData = msg.readArrayUint8(16, 'DatabaseData')
|
||||||
self.log.debug("MsgData:" + str(MsgData))
|
self.log.debug("MsgData:" + str(MsgData))
|
||||||
self.log.debug("DatabaseData:" + str(DatabaseData))
|
self.log.debug("DatabaseData:" + str(DatabaseData))
|
||||||
md5Msg = bytes(MsgData)
|
md5Msg = bytes(MsgData)
|
||||||
|
@ -2862,7 +2935,7 @@ class ClientNetworkConnection:
|
||||||
def stateLogin(self, msgin):
|
def stateLogin(self, msgin):
|
||||||
self.decodeHeader(msgin)
|
self.decodeHeader(msgin)
|
||||||
if self._SystemMode:
|
if self._SystemMode:
|
||||||
message = msgin.readUint8()
|
message = msgin.readUint8('message')
|
||||||
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
||||||
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
||||||
self._ConnectionState = TConnectionState.Synchronize
|
self._ConnectionState = TConnectionState.Synchronize
|
||||||
|
@ -2893,7 +2966,7 @@ class ClientNetworkConnection:
|
||||||
def stateSynchronize(self, msgin):
|
def stateSynchronize(self, msgin):
|
||||||
self.decodeHeader(msgin)
|
self.decodeHeader(msgin)
|
||||||
if self._SystemMode:
|
if self._SystemMode:
|
||||||
message = msgin.readUint8()
|
message = msgin.readUint8('message')
|
||||||
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
||||||
if message == CLFECOMMON.SYSTEM_PROBE_CODE:
|
if message == CLFECOMMON.SYSTEM_PROBE_CODE:
|
||||||
self.log.debug("synchronize->probe")
|
self.log.debug("synchronize->probe")
|
||||||
|
@ -2928,7 +3001,7 @@ class ClientNetworkConnection:
|
||||||
def stateConnected(self, msgin):
|
def stateConnected(self, msgin):
|
||||||
self.decodeHeader(msgin)
|
self.decodeHeader(msgin)
|
||||||
if self._SystemMode:
|
if self._SystemMode:
|
||||||
message = msgin.readUint8()
|
message = msgin.readUint8('message')
|
||||||
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
||||||
if message == CLFECOMMON.SYSTEM_PROBE_CODE:
|
if message == CLFECOMMON.SYSTEM_PROBE_CODE:
|
||||||
self.log.debug("Connected->probe")
|
self.log.debug("Connected->probe")
|
||||||
|
@ -2959,7 +3032,7 @@ class ClientNetworkConnection:
|
||||||
def stateProbe(self, msgin):
|
def stateProbe(self, msgin):
|
||||||
self.decodeHeader(msgin)
|
self.decodeHeader(msgin)
|
||||||
if self._SystemMode:
|
if self._SystemMode:
|
||||||
message = msgin.readUint8()
|
message = msgin.readUint8('message')
|
||||||
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
||||||
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
||||||
self.log.debug("probe->synchronize")
|
self.log.debug("probe->synchronize")
|
||||||
|
@ -2992,7 +3065,7 @@ class ClientNetworkConnection:
|
||||||
def stateStalled(self, msgin):
|
def stateStalled(self, msgin):
|
||||||
self.decodeHeader(msgin)
|
self.decodeHeader(msgin)
|
||||||
if self._SystemMode:
|
if self._SystemMode:
|
||||||
message = msgin.readUint8()
|
message = msgin.readUint8('message')
|
||||||
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
||||||
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
||||||
self.log.debug("stalled->synchronize")
|
self.log.debug("stalled->synchronize")
|
||||||
|
@ -3019,7 +3092,7 @@ class ClientNetworkConnection:
|
||||||
def stateQuit(self, msgin):
|
def stateQuit(self, msgin):
|
||||||
self.decodeHeader(msgin)
|
self.decodeHeader(msgin)
|
||||||
if self._SystemMode:
|
if self._SystemMode:
|
||||||
message = msgin.readUint8()
|
message = msgin.readUint8('message')
|
||||||
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
self.log.debug("_CurrentReceivedNumber:%d (mode:%s) %d [%d/%d/%d]" % (self._CurrentReceivedNumber, str(self._SystemMode), message, msgin.sizeData(), msgin.sizeRead(), msgin.needRead()))
|
||||||
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
if message == CLFECOMMON.SYSTEM_SYNC_CODE:
|
||||||
self.log.debug("quit->synchronize")
|
self.log.debug("quit->synchronize")
|
||||||
|
|
Loading…
Reference in a new issue