BattlenetRpcErrorCode JoinRealm(Dictionary <string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response) { Variant realmAddress = GetParam(Params, "Param_RealmAddress"); if (realmAddress != null) { return(Global.RealmMgr.JoinRealm((uint)realmAddress.UintValue, _build, GetRemoteIpAddress(), _clientSecret, (LocaleConstant)Enum.Parse(typeof(LocaleConstant), _locale), _os, _gameAccountInfo.Name, response)); } return(BattlenetRpcErrorCode.WowServicesInvalidJoinTicket); }
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); }
BattlenetRpcErrorCode GetLastCharPlayed(Dictionary <string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response) { Variant subRegion = GetParam(Params, "Command_LastCharPlayedRequest_v1_b9"); if (subRegion != null) { var lastPlayerChar = _gameAccountInfo.LastPlayedCharacters.LookupByKey(subRegion.StringValue); if (lastPlayerChar != null) { var compressed = Global.RealmMgr.GetRealmEntryJSON(lastPlayerChar.RealmId, _build); if (compressed.Length == 0) { return(BattlenetRpcErrorCode.UtilServerFailedToSerializeResponse); } var attribute = new Bgs.Protocol.Attribute(); attribute.Name = "Param_RealmEntry"; attribute.Value = new Variant(); attribute.Value.BlobValue = ByteString.CopyFrom(compressed); response.Attribute.Add(attribute); attribute = new Bgs.Protocol.Attribute(); attribute.Name = "Param_CharacterName"; attribute.Value = new Variant(); attribute.Value.StringValue = lastPlayerChar.CharacterName; response.Attribute.Add(attribute); attribute = new Bgs.Protocol.Attribute(); attribute.Name = "Param_CharacterGUID"; attribute.Value = new Variant(); attribute.Value.BlobValue = ByteString.CopyFrom(BitConverter.GetBytes(lastPlayerChar.CharacterGUID)); response.Attribute.Add(attribute); attribute = new Bgs.Protocol.Attribute(); attribute.Name = "Param_LastPlayedTime"; attribute.Value = new Variant(); attribute.Value.IntValue = (int)lastPlayerChar.LastPlayedTime; response.Attribute.Add(attribute); } return(BattlenetRpcErrorCode.Ok); } return(BattlenetRpcErrorCode.UtilServerUnknownRealm); }
BattlenetRpcErrorCode GetRealmListTicket(Dictionary <string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response) { Variant identity = GetParam(Params, "Param_Identity"); if (identity != null) { var realmListTicketIdentity = Json.CreateObject <RealmListTicketIdentity>(identity.BlobValue.ToStringUtf8(), true); var gameAccountInfo = _accountInfo.GameAccounts.LookupByKey(realmListTicketIdentity.GameAccountId); if (gameAccountInfo != null) { _gameAccountInfo = gameAccountInfo; } } if (_gameAccountInfo == null) { return(BattlenetRpcErrorCode.UtilServerInvalidIdentityArgs); } if (_gameAccountInfo.IsPermanenetlyBanned) { return(BattlenetRpcErrorCode.GameAccountBanned); } else if (_gameAccountInfo.IsBanned) { return(BattlenetRpcErrorCode.GameAccountSuspended); } bool clientInfoOk = false; Variant clientInfo = GetParam(Params, "Param_ClientInfo"); if (clientInfo != null) { var realmListTicketClientInformation = Json.CreateObject <RealmListTicketClientInformation>(clientInfo.BlobValue.ToStringUtf8(), true); clientInfoOk = true; _clientSecret.AddRange(realmListTicketClientInformation.Info.Secret.Select(x => Convert.ToByte(x)).ToArray()); } if (!clientInfoOk) { return(BattlenetRpcErrorCode.WowServicesDeniedRealmListTicket); } PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_LAST_LOGIN_INFO); stmt.AddValue(0, GetRemoteIpAddress().ToString()); stmt.AddValue(1, Enum.Parse(typeof(LocaleConstant), _locale)); stmt.AddValue(2, _os); stmt.AddValue(3, _accountInfo.Id); DB.Login.Execute(stmt); var attribute = new Bgs.Protocol.Attribute(); attribute.Name = "Param_RealmListTicket"; attribute.Value = new Variant(); attribute.Value.BlobValue = ByteString.CopyFrom("AuthRealmListTicket", System.Text.Encoding.UTF8); response.Attribute.Add(attribute); return(BattlenetRpcErrorCode.Ok); }
public BattlenetRpcErrorCode HandleProcessClientRequest(Bgs.Protocol.GameUtilities.V1.ClientRequest request, Bgs.Protocol.GameUtilities.V1.ClientResponse response) { if (!_authed) { return(BattlenetRpcErrorCode.Denied); } Bgs.Protocol.Attribute command = null; Dictionary <string, Variant> Params = new Dictionary <string, 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.", GetClientInfo()); return(BattlenetRpcErrorCode.RpcMalformedRequest); } var handler = ClientRequestHandlers.LookupByKey(command.Name); if (handler == null) { Log.outError(LogFilter.SessionRpc, "{0} sent ClientRequest with unknown command {1}.", GetClientInfo(), command.Name); return(BattlenetRpcErrorCode.RpcNotImplemented); } return(handler(Params, response)); }