def request(tcpclient, type, router, data, pb): module = __import__(pb[0], globals(), locals(), [pb[1]]) c = getattr(module, pb[1])() for k, v in data.items(): setattr(c, k, v) req_data = c.SerializeToString() msg = Message(type, route=router, body=req_data) protocol_pack = Protocol(Protocol.PROTO_TYPE_DATA, msg.encode()) return tcpclient.send(protocol_pack.pack())
def login(tcpclient, token): model = pb.login_msg_pb2.LoginRequest() model.SessionToken = token model.BundleIdentifier = config.GAME["NAME"] req_data = model.SerializeToString() msg = Message(Message.MSG_TYPE_REQUEST, route='Login/ReqLogin', body=req_data) protocol_pack = Protocol(Protocol.PROTO_TYPE_DATA, msg.encode()) return tcpclient.send(protocol_pack.pack())