Exemple #1
0
def ParseYYPResponse(input):
    buf = readfull(input, 10)
    datasize, uri, respCode = struct.unpack("<IIH", buf)
    if datasize < 10:
        raise YYPException("invalid data size: %s !" % datasize)
    data = readfull(input, datasize - 10)
    return YYPResponse(datasize, uri, respCode, data)
def ParseYYPMobileResponse(input):
    buf = readfull(input, 4)
    datasize = struct.unpack("<I", buf)[0]
    if datasize < 38:
        raise YYPException("invalid data size: %s !" % datasize)
    data = readfull(input, datasize - 4)

    u = YYPUnMarshal(data)
    serviceUri = u.popUInt32()
    respCode = u.popUInt16()
    mobileAppId = u.popUInt32()
    mobileTopChannel = u.popUInt32()
    mobileSubChannel = u.popUInt32()
    uid = u.popUInt32()
    sendType = u.popUInt32()
    response = u.popString16()
    uids = u.popList(YYP_UINT32)

    u2 = YYPUnMarshal(response)
    mobileUri = u2.popUInt32()
    mobileExtendMap = u2.popDict(YYP_INT16, YYP_STRING16)
    response2 = u2.popString16()


    r = YYPMobileResponse(response2)

    r.serviceUri = serviceUri
    r.respCode = respCode
    r.mobileAppId = mobileAppId
    r.mobileTopChannel = mobileTopChannel
    r.mobileSubChannel = mobileSubChannel
    r.uid = uid
    r.sendType = sendType
    r.uids = uids

    r.mobileUri = mobileUri
    r.mobileExtendMap = mobileExtendMap

    return r
Exemple #3
0
def ParseYYPMobileResponse(input):
    buf = readfull(input, 4)
    datasize = struct.unpack("<I", buf)[0]
    if datasize < 38:
        raise YYPException("invalid data size: %s !" % datasize)
    data = readfull(input, datasize - 4)

    u = YYPUnMarshal(data)
    serviceUri = u.popUInt32()
    respCode = u.popUInt16()
    mobileAppId = u.popUInt32()
    mobileTopChannel = u.popUInt32()
    mobileSubChannel = u.popUInt32()
    uid = u.popUInt32()
    sendType = u.popUInt32()
    response = u.popString16()
    uids = u.popList(YYP_UINT32)

    u2 = YYPUnMarshal(response)
    mobileUri = u2.popUInt32()
    mobileExtendMap = u2.popDict(YYP_INT16, YYP_STRING16)
    response2 = u2.popString16()

    r = YYPMobileResponse(response2)

    r.serviceUri = serviceUri
    r.respCode = respCode
    r.mobileAppId = mobileAppId
    r.mobileTopChannel = mobileTopChannel
    r.mobileSubChannel = mobileSubChannel
    r.uid = uid
    r.sendType = sendType
    r.uids = uids

    r.mobileUri = mobileUri
    r.mobileExtendMap = mobileExtendMap

    return r
Exemple #4
0
 def pop(self, type):
     if (type == YYP_INT8):
         buf = readfull(self._in, 1)
         return struct.unpack('<b', buf)[0]
     elif (type == YYP_INT16):
         buf = readfull(self._in, 2)
         return struct.unpack('<h', buf)[0]
     elif (type == YYP_INT32):
         buf = readfull(self._in, 4)
         return struct.unpack('<i', buf)[0]
     elif (type == YYP_INT64):
         buf = readfull(self._in, 8)
         return struct.unpack('<q', buf)[0]
     elif (type == YYP_UINT8):
         buf = readfull(self._in, 1)
         return struct.unpack('<B', buf)[0]
     elif (type == YYP_UINT16):
         buf = readfull(self._in, 2)
         return struct.unpack('<H', buf)[0]
     elif (type == YYP_UINT32):
         buf = readfull(self._in, 4)
         return struct.unpack('<I', buf)[0]
     elif (type == YYP_UINT64):
         buf = readfull(self._in, 8)
         return struct.unpack('<Q', buf)[0]
     elif (type == YYP_FLOAT32):
         buf = readfull(self._in, 4)
         return struct.unpack('<f', buf)[0]
     elif (type == YYP_FLOAT64):
         buf = readfull(self._in, 8)
         return struct.unpack('<d', buf)[0]
     elif (type == YYP_STRING16):
         buf = readfull(self._in, 2)
         l = struct.unpack('<H', buf)[0]
         if l <= 0:
             return ""
         return readfull(self._in, l)
     elif (type == YYP_STRING32):
         buf = readfull(self._in, 4)
         l = struct.unpack('<I', buf)[0]
         if l <= 0:
             return ""
         return readfull(self._in, l)
     else:
         raise YYPException("Invalid type %s" % type)