Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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
Example #6
0
 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
Example #7
0
def UAnsDB(db):
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSDB
    ans.ansDB.CopyFrom(db)
    return ans
Example #8
0
def GLAnsGameProtocol(ansGameProtocol):
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.GLANSGAMEPROTOCOL
    ans.ansGameProtocol.CopyFrom(ansGameProtocol)
    return ans
Example #9
0
def UAnsPong(seq):
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSPONG
    ans.ansPong.seq = seq
    return ans
Example #10
0
def UAnsClose():
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSCLOSE
    ans.ansClose.CopyFrom(ug_pb2.UAnsClose())
    return ans
Example #11
0
def UAnsPlug(gameID):
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSPLUG
    ans.ansPlug.gameID = gameID
    return ans
Example #12
0
def UAnsLeaveGame(gameID, type):
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSLEAVEGAME
    ans.ansLeaveGame.gameID = gameID
    ans.ansLeaveGame.nType = type
    return ans
Example #13
0
def UAnsAutoJoin(gameRoomInfo):
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSAUTOJOIN
    ans.ansAutoJoin.gameRoomInfo.CopyFrom(gameRoomInfo)
    return ans
Example #14
0
def UAnsInfo(gameInfo):
    print gameInfo
    ans = ug_pb2.UAnsProtocol()
    ans.type = ug_pb2.UAnsProtocol.UANSINFO
    ans.ansInfo.gameInfo.CopyFrom(gameInfo)
    return ans