def UError(mode, code, info): req = ug_pb2.UAnsProtocol() req.type = ug_pb2.UAnsProtocol.UERROR req.ansError.error.errorCode = code req.ansError.error.errorInfo = info req.ansError.error.reqMode = mode return req
def UAnsNotice(notice): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSNOTICE for i in notice: notice = ans.ansNotice.notices.add() notice.popup = i[0] notice.srl = i[1] notice.notice = i[2] return ans
def UAnsStore(itemInfo): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSSTORE store = ug_pb2.UAnsStore() ans.ansStore.CopyFrom(store) for k, v in itemInfo.iteritems(): item = ans.ansStore.itemInfo.add() item.id = k item.desc = v return ans
def UAnsChannel(chanList): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSCHANNEL index = 0 for i in chanList: chan = ans.ansChannel.channelInfo.add() chan.id = index chan.desc = i index = index + 1 return ans
def UAnsConnect(svcID, gameID, status, ip, port, passwd): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSCONNECT ans.ansConnect.svcID = svcID ans.ansConnect.gameID = gameID ans.ansConnect.status = status ans.ansConnect.ip = ip ans.ansConnect.port = port ans.ansConnect.passwd = passwd return ans
def rcvAns(self): self.buffer += self.sock.recv(1024) print len(self.buffer) if len(self.buffer) > 4: (size, ) = unpack('I', self.buffer[0:4]) size += 4 if len(self.buffer) >= size: ans = self.buffer[4:size] self.buffer = self.buffer[size:] if size > 4: ret = ug_pb2.UAnsProtocol() ret.ParseFromString(ans) return ret return False
def UAnsDB(db): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSDB ans.ansDB.CopyFrom(db) return ans
def GLAnsGameProtocol(ansGameProtocol): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.GLANSGAMEPROTOCOL ans.ansGameProtocol.CopyFrom(ansGameProtocol) return ans
def UAnsPong(seq): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSPONG ans.ansPong.seq = seq return ans
def UAnsClose(): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSCLOSE ans.ansClose.CopyFrom(ug_pb2.UAnsClose()) return ans
def UAnsPlug(gameID): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSPLUG ans.ansPlug.gameID = gameID return ans
def UAnsLeaveGame(gameID, type): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSLEAVEGAME ans.ansLeaveGame.gameID = gameID ans.ansLeaveGame.nType = type return ans
def UAnsAutoJoin(gameRoomInfo): ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSAUTOJOIN ans.ansAutoJoin.gameRoomInfo.CopyFrom(gameRoomInfo) return ans
def UAnsInfo(gameInfo): print gameInfo ans = ug_pb2.UAnsProtocol() ans.type = ug_pb2.UAnsProtocol.UANSINFO ans.ansInfo.gameInfo.CopyFrom(gameInfo) return ans