コード例 #1
0
        BattlenetRpcErrorCode GetRealmList(Dictionary <string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response)
        {
            if (_gameAccountInfo == null)
            {
                return(BattlenetRpcErrorCode.UserServerBadWowAccount);
            }

            string  subRegionId = "";
            Variant subRegion   = GetParam(Params, "Command_RealmListRequest_v1_b9");

            if (subRegion != null)
            {
                subRegionId = subRegion.StringValue;
            }

            var compressed = Global.RealmMgr.GetRealmList(_build, subRegionId);

            if (compressed.Length == 0)
            {
                return(BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse);
            }

            var attribute = new Bgs.Protocol.Attribute();

            attribute.Name            = "Param_RealmList";
            attribute.Value           = new Variant();
            attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
            response.Attribute.Add(attribute);

            var realmCharacterCounts = new RealmCharacterCountList();

            foreach (var characterCount in _gameAccountInfo.CharacterCounts)
            {
                var countEntry = new RealmCharacterCountEntry();
                countEntry.WowRealmAddress = (int)characterCount.Key;
                countEntry.Count           = characterCount.Value;
                realmCharacterCounts.Counts.Add(countEntry);
            }

            compressed = Json.Deflate("JSONRealmCharacterCountList", realmCharacterCounts);

            attribute                 = new Bgs.Protocol.Attribute();
            attribute.Name            = "Param_CharacterCountList";
            attribute.Value           = new Variant();
            attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
            response.Attribute.Add(attribute);
            return(BattlenetRpcErrorCode.Ok);
        }
コード例 #2
0
        BattlenetRpcErrorCode HandleRealmListRequest(Dictionary <string, Bgs.Protocol.Variant> Params, ClientResponse response)
        {
            string subRegionId = "";
            var    subRegion   = Params.LookupByKey("Command_RealmListRequest_v1_b9");

            if (subRegion != null)
            {
                subRegionId = subRegion.StringValue;
            }

            var compressed = Global.RealmMgr.GetRealmList(Global.WorldMgr.GetRealm().Build, subRegionId);

            if (compressed.Empty())
            {
                return(BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse);
            }

            Bgs.Protocol.Attribute attribute = new Bgs.Protocol.Attribute();
            attribute.Name            = "Param_RealmList";
            attribute.Value           = new Bgs.Protocol.Variant();
            attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
            response.Attribute.Add(attribute);

            var realmCharacterCounts = new RealmCharacterCountList();

            foreach (var characterCount in _session.GetRealmCharacterCounts())
            {
                RealmCharacterCountEntry countEntry = new RealmCharacterCountEntry();
                countEntry.WowRealmAddress = (int)characterCount.Key;
                countEntry.Count           = characterCount.Value;
                realmCharacterCounts.Counts.Add(countEntry);
            }
            compressed = Json.Deflate("JSONRealmCharacterCountList", realmCharacterCounts);

            attribute                 = new Bgs.Protocol.Attribute();
            attribute.Name            = "Param_CharacterCountList";
            attribute.Value           = new Bgs.Protocol.Variant();
            attribute.Value.BlobValue = ByteString.CopyFrom(compressed);
            response.Attribute.Add(attribute);
            return(BattlenetRpcErrorCode.Ok);
        }