BattlenetRpcErrorCode HandleProcessClientRequest(ClientRequest request, ClientResponse response) { Bgs.Protocol.Attribute command = null; Dictionary <string, Bgs.Protocol.Variant> Params = new Dictionary <string, Bgs.Protocol.Variant>(); for (int i = 0; i < request.Attribute.Count; ++i) { Bgs.Protocol.Attribute attr = request.Attribute[i]; Params[attr.Name] = attr.Value; if (attr.Name.Contains("Command_")) { command = attr; } } if (command == null) { Log.outError(LogFilter.SessionRpc, "{0} sent ClientRequest with no command.", GetCallerInfo()); return(BattlenetRpcErrorCode.RpcMalformedRequest); } if (command.Name == "Command_RealmListRequest_v1_b9") { return(HandleRealmListRequest(Params, response)); } else if (command.Name == "Command_RealmJoinRequest_v1_b9") { return(HandleRealmJoinRequest(Params, response)); } return(BattlenetRpcErrorCode.RpcNotImplemented); }
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); }