public static void OnGetRankTop8(
            funapi.Leaderboard.QueryRequest request, funapi.Leaderboard.QueryResponse response,
            bool error, Session session, Session.EncodingScheme encoding, bool single)
        {
            if (error)
            {
                Log.Error("Failed to query leaderboard. Leaderboard system error.");
                return;
            }
            string msgtype = single ? "ranklist_single" : "ranklist";

            if (encoding == Session.EncodingScheme.kJsonEncoding)
            {
                JObject result = new JObject();
                result ["ranks"] = new JObject();
                int index = 0;
                foreach (funapi.Leaderboard.Record record in response.Records)
                {
                    string index_str = index.ToString();
                    result ["ranks"] [index_str]           = new JObject();
                    result ["ranks"] [index_str] ["rank"]  = record.Rank;
                    result ["ranks"] [index_str] ["score"] = record.Score;
                    result ["ranks"] [index_str] ["id"]    = record.PlayerAccount.Id;
                    ++index;
                }
                session.SendMessage(msgtype, result, Session.Encryption.kDefault);
            }
            else
            {
                Log.Assert(encoding == Session.EncodingScheme.kProtobufEncoding);

                FunMessage         message = new FunMessage();
                LobbyRankListReply reply   = new LobbyRankListReply();
                reply.result = "Success";
                int index = 0;
                foreach (funapi.Leaderboard.Record record in response.Records)
                {
                    LobbyRankListReply.RankElement el = new LobbyRankListReply.RankElement();
                    string index_str = index.ToString();
                    el.rank  = record.Rank;
                    el.score = (int)record.Score;
                    el.id    = record.PlayerAccount.Id;
                    reply.rank.Add(el);
                    ++index;
                }
                message.AppendExtension_lobby_rank_list_repl(reply);
                session.SendMessage(msgtype, message, Session.Encryption.kDefault);
            }
        }
Ejemplo n.º 2
0
 public static void AppendExtension_lobby_rank_list_repl(this FunMessage message, LobbyRankListReply value)
 {
     ProtoBuf.Extensible.AppendValue(message, (int)ExtendedMessageFieldNumber.FunMessage_lobby_rank_list_repl, value);
 }
Ejemplo n.º 3
0
 public static bool TryGetExtension_lobby_rank_list_repl(this FunMessage message, out LobbyRankListReply value)
 {
     return(ProtoBuf.Extensible.TryGetValue(message, (int)ExtendedMessageFieldNumber.FunMessage_lobby_rank_list_repl, out value));
 }