コード例 #1
0
ファイル: MessageTest.py プロジェクト: brodie20j/PyClient
    def testEncodingWithExtension(self):
        msg=ClientMessage()
        vr=0
        optype=200
        corrID=0
        parID=-1

        msg.version=vr
        msg.optype=optype
        msg.correlation=corrID
        msg.partition=parID
        msg.addExtension(bytearray(ctypes.c_uint32(4203239)))
        frame = bytearray()
        #Create a byte array of size 18


        frame+=bytearray(ctypes.c_int32(18+4))
        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(22))
        frame+=bytearray(ctypes.c_uint32(4203239))

        encodedMsg=msg.encodeMessage()


        self.assertEqual(frame,encodedMsg)
コード例 #2
0
ファイル: MessageTest.py プロジェクト: brodie20j/PyClient
    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())
コード例 #3
0
ファイル: alongcodec.py プロジェクト: brodie20j/PyClient
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
コード例 #4
0
ファイル: alongcodec.py プロジェクト: brodie20j/PyClient
def getandsetEncode(title,new):
    msg=ClientMessage()
    msg.optype=0x0a0a
    msg.correlation=127
    msg.partition=1
    newtitle=title.encode("UTF8")
    payload=bytearray(ctypes.c_uint32(len(newtitle)))+newtitle+bytearray(ctypes.c_uint32(new))
    msg.setPayload(payload)
    return msg
コード例 #5
0
ファイル: alongcodec.py プロジェクト: brodie20j/PyClient
def compareandsetEncode(title,expected,updated):
    msg=ClientMessage()
    msg.optype=0x0a06
    msg.correlation=126
    msg.partition=1
    newtitle=title.encode("UTF8")
    payload=bytearray(ctypes.c_uint32(len(newtitle)))+newtitle+bytearray(ctypes.c_uint32(expected))+bytearray(ctypes.c_uint32(updated))
    msg.setPayload(payload)
    return msg
コード例 #6
0
ファイル: alongcodec.py プロジェクト: brodie20j/PyClient
def addandgetEncode(title,delta):
    msg=ClientMessage()
    msg.optype=0x0a05
    msg.correlation=125
    msg.partition=1
    newtitle=title.encode("UTF8")
    payload=bytearray(ctypes.c_uint32(len(newtitle)))+newtitle+bytearray(ctypes.c_uint32(delta))
    msg.setPayload(payload)
    return msg