Exemplo n.º 1
0
    def taf_invoke(self, cPacketType, sFuncName, sBuffer, context, status):
        req = RequestPacket()
        req.iVersion = ServantProxy.JCEVERSION
        req.cPacketType = cPacketType
        req.iMessageType = ServantProxy.JCEMESSAGETYPENULL
        req.iRequestId = 0
        req.sServantName = self.sServantName
        req.sFuncName = sFuncName
        req.sBuffer = sBuffer
        req.iTimeout = self.iTimeout

        oos = JceOutputStream()
        RequestPacket.writeTo(oos, req)

        reqpkt = oos.getBuffer()
        plen = len(reqpkt) + 4
        reqpkt = struct.pack('!i', plen) + reqpkt

        ret = self.__trans(reqpkt, plen)
        if len(ret) == 0:
            raise Exception('server do not response')

        ios = JceInputStream(ret)
        rsp = ResponsePacket.readFrom(ios)
        if rsp.iRet != 0:
            raise Exception("Taf Error:%d" % rsp.iRet)
        return rsp
Exemplo n.º 2
0
 def encode(self):
     oos = JceOutputStream()
     oos.write(self.__mapv, 0, self.__buffer)
     self.__code.iVersion = 2
     self.__code.sBuffer = oos.getBuffer()
     sos = JceOutputStream()
     RequestPacket.writeTo(sos, self.__code)
     return struct.pack('!i', 4 + len(sos.getBuffer())) + sos.getBuffer()
Exemplo n.º 3
0
    def encode(self):
        oos = TarsOutputStream();
        oos.write(self.__mapv, 0, self.__buffer); 

        self.__code.iVersion = 2;
        self.__code.sBuffer = oos.getBuffer();

        sos = TarsOutputStream();
        RequestPacket.writeTo(sos, self.__code);

        return struct.pack('!i', 4 + len(sos.getBuffer())) + sos.getBuffer(); 
Exemplo n.º 4
0
    def encode(self):
        oos = TarsOutputStream();
        oos.write(self.__mapv, 0, self.__buffer); 

        self.__code.iVersion = 2;
        self.__code.sBuffer = oos.getBuffer();

        sos = TarsOutputStream();
        RequestPacket.writeTo(sos, self.__code);

        return struct.pack('!i', 4 + len(sos.getBuffer())) + sos.getBuffer(); 
Exemplo n.º 5
0
 def packReq(self):
     '''
     @brief: 序列化请求报文
     @return: 序列化后的请求报文
     @rtype: str
     '''
     if not self.request:
         return ''
     oos = TarsOutputStream()
     RequestPacket.writeTo(oos, self.request)
     reqpkt = oos.getBuffer()
     plen = len(reqpkt) + 4
     reqpkt = struct.pack('!i', plen) + reqpkt
     return reqpkt