Example #1
0
 def subscribe(self, func, params):
     self.seq += 1
     d = {u"func": func, u"params": params}
     sendPack = TTPackage(self.seq, NET_CMD_RPC, d)
     datas = sendPack.encode()
     self.socket.sendall(datas)
     return self.seq
Example #2
0
 def subscribe(self, func, params):
     self.seq += 1
     d = {u"func": func, u"params": params}
     sendPack = TTPackage(self.seq, NET_CMD_RPC, d)
     datas = sendPack.encode()
     self.socket.sendall(datas)
     return self.seq
Example #3
0
 def _recvOnePackage(self):
     strLen = self._recv_all(4)
     packLen, = struct.unpack_from("!I", strLen, 0)
     strContent = self._recv_all(packLen - 4)
     datas = strLen + strContent
     package = TTPackage()
     package.decode(datas)
     return package
Example #4
0
 def _recvOnePackage(self):
     strLen = self._recv_all(4)
     packLen, = struct.unpack_from("!I", strLen, 0)
     strContent = self._recv_all(packLen - 4)
     datas = strLen + strContent
     package = TTPackage()
     package.decode(datas)
     return package
Example #5
0
 def request(self, func, params):
     self.seq += 1
     d = {u"func": func, u"params": params}
     sendPack = TTPackage(self.seq, NET_CMD_RPC, d)
     datas = sendPack.encode()
     self.socket.sendall(datas)
     while True:
         recvPack = self._recvOnePackage()
         if recvPack.seq == self.seq:
             if recvPack.data["status"] == 0:
                 return recvPack.data[u"params"]
             else:
                 raise Exception(recvPack.data[u"params"])
         else:
             if self.handler:
                 self.handler.handle_sub_pack(recvPack.data[u"params"])
Example #6
0
 def request(self, func, params):
     self.seq += 1
     d = {u"func": func, u"params": params}
     sendPack = TTPackage(self.seq, NET_CMD_RPC, d)
     datas = sendPack.encode()
     self.socket.sendall(datas)
     while True:
         recvPack = self._recvOnePackage()
         if recvPack.seq == self.seq:
             if recvPack.data["status"] == [0] or recvPack.data["status"] == 0:
                 return recvPack.data[u"params"]
             else:
                 raise Exception(recvPack.data[u"params"])
         else:
             if self.handler:
                 self.handler.handle_sub_pack(recvPack.data[u"params"])