Ejemplo n.º 1
0
    def testEncoding(self):
        msg=ClientMessage()
        vr=0
        optype=200
        corrID=0
        parID=-1

        msg.setVersion(vr)
        msg.setFlagBoth()
        msg.setOperationType(200)
        msg.correlation=corrID
        msg.setPartition(parID)

        frame = bytearray()

        #Create a byte array of size 18
        frame+=bytearray(ctypes.c_int32(18))
        frame+=bytearray(ctypes.c_uint8(vr))
        frame+=bytearray(ctypes.c_uint8(192))
        frame+=bytearray(ctypes.c_uint16(optype))
        frame+=bytearray(ctypes.c_int32(corrID))
        frame+=bytearray(ctypes.c_int32(parID))
        frame+=bytearray(ctypes.c_uint16(18))

        self.assertEqual(frame,msg.encodeMessage())
Ejemplo n.º 2
0
def getandincrementEncode(title):
    msg=ClientMessage()
    msg.optype=0x0a0c
    msg.correlation=129
    msg.setPartition(1)
    newtitle=title.encode("UTF8")
    payload=bytearray(ctypes.c_uint32(len(newtitle)))+newtitle
    msg.setPayload(payload)
    return msg