Beispiel #1
0
    def get(self, vtype, name):
        if self.__buffer.has_key(name) == False:
            raise Exception("UniAttribute not found key:%s,type:%s" % (name, vtype.__tars_class__));

        t = self.__buffer[name];
        if t.has_key(vtype.__tars_class__) == False:
            raise Exception("UniAttribute not found type:" + vtype.__tars_class__);

        o = TarsInputStream(t[vtype.__tars_class__]);
        return o.read(vtype, 0, True);
Beispiel #2
0
    def get(self, vtype, name):
        if self.__buffer.has_key(name) == False:
            raise Exception("UniAttribute not found key:%s,type:%s" % (name, vtype.__tars_class__));

        t = self.__buffer[name];
        if t.has_key(vtype.__tars_class__) == False:
            raise Exception("UniAttribute not found type:" + vtype.__tars_class__);

        o = TarsInputStream(t[vtype.__tars_class__]);
        return o.read(vtype, 0, True);
Beispiel #3
0
    def unpackRspList(buf):
        '''
        @brief: 解码响应报文
        @param buf: 多个序列化后的响应报文数据
        @type buf: str
        @return: 解码出来的响应报文和解码的buffer长度
        @rtype: rsplist: 装有ResponsePacket的list
                unpacklen: int
        '''
        rsplist = []
        if not buf:
            return rsplist

        unpacklen = 0
        buf = buffer(buf)
        while True:
            if len(buf) - unpacklen < 4:
                break
            packsize = buf[unpacklen:unpacklen + 4]
            packsize, = struct.unpack_from('!i', packsize)
            if len(buf) < unpacklen + packsize:
                break

            ios = TarsInputStream(buf[unpacklen + 4:unpacklen + packsize])
            rsp = ResponsePacket.readFrom(ios)
            rsplist.append(rsp)
            unpacklen += packsize

        return rsplist, unpacklen
Beispiel #4
0
    def decode(self, buf):
        ois = TarsInputStream(buf[4:])
        self.__code = RequestPacket.readFrom(ois)

        sis = TarsInputStream(self.__code.sBuffer)
        self.__buffer = sis.read(self.__mapv, 0, True)
Beispiel #5
0
    def decode(self, buf):
        ois = TarsInputStream(buf[4:]);
        self.__code = RequestPacket.readFrom(ois);

        sis = TarsInputStream(self.__code.sBuffer);
        self.__buffer = sis.read(self.__mapv, 0, True);