Ported .Net Core commits:
hondacrx: - Initial commit: Switch to .Net Core 2.0 - Fix build and removed not needed files Fabi: - Updated solution platforms. - Changed folder structure. - Change library target framework to netstandard2.0. - Updated solution platforms again... - Removed windows specific kernel32 function usage (Ctrl-C handler).
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
###################################################################################################
|
||||
# Cypher BNet Server Configuration File #
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# BNet SERVER SETTINGS
|
||||
#
|
||||
# LogsDir
|
||||
# Description: Logs directory setting.
|
||||
# Important: LogsDir needs to be quoted, as the string might contain space characters.
|
||||
# Logs directory must exists, or log file creation will be disabled.
|
||||
# Default: "" - (Log files will be stored in the current path)
|
||||
|
||||
LogsDir = "./Logs"
|
||||
|
||||
#
|
||||
# BattlenetPort
|
||||
# Description: TCP port to reach the auth server for battle.net connections.
|
||||
# Default: 1119
|
||||
|
||||
BattlenetPort = 1119
|
||||
|
||||
#
|
||||
# LoginREST.Port
|
||||
# Description: TCP port to reach the REST login method.
|
||||
# Default: 8081
|
||||
#
|
||||
# LoginREST.ExternalAddress
|
||||
# Description: IP address sent to clients connecting from outside the network where bnetserver runs
|
||||
#
|
||||
# LoginREST.LocalAddress
|
||||
# Description: IP address sent to clients connecting from inside the network where bnetserver runs
|
||||
#
|
||||
|
||||
LoginREST.Port = 8081
|
||||
LoginREST.ExternalAddress=127.0.0.1
|
||||
LoginREST.LocalAddress=127.0.0.1
|
||||
|
||||
#
|
||||
# BindIP
|
||||
# Description: Bind auth server to IP/hostname
|
||||
# Default: "0.0.0.0" - (Bind to all IPs on the system)
|
||||
|
||||
BindIP = "0.0.0.0"
|
||||
|
||||
#
|
||||
# RealmsStateUpdateDelay
|
||||
# Description: Time (in seconds) between realm list updates.
|
||||
# Default: 10
|
||||
# 0 - (Disabled)
|
||||
|
||||
RealmsStateUpdateDelay = 10
|
||||
|
||||
#
|
||||
# WrongPass.MaxCount
|
||||
# Description: Number of login attemps with wrong password before the account or IP will be
|
||||
# banned.
|
||||
# Default: 0 - (Disabled)
|
||||
# 1+ - (Enabled)
|
||||
|
||||
WrongPass.MaxCount = 0
|
||||
|
||||
#
|
||||
# WrongPass.BanTime
|
||||
# Description: Time (in seconds) for banning account or IP for invalid login attempts.
|
||||
# Default: 600 - (10 minutes)
|
||||
# 0 - (Permanent ban)
|
||||
|
||||
WrongPass.BanTime = 600
|
||||
|
||||
#
|
||||
# WrongPass.BanType
|
||||
# Description: Ban type for invalid login attempts.
|
||||
# Default: 0 - (Ban IP)
|
||||
# 1 - (Ban Account)
|
||||
|
||||
WrongPass.BanType = 0
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# MYSQL SETTINGS
|
||||
#
|
||||
# LoginDatabaseInfo
|
||||
# Description: Database connection settings for the realm server.
|
||||
# Example: "hostname;port;username;password;database"
|
||||
|
||||
LoginDatabaseInfo.Host = "127.0.0.1"
|
||||
LoginDatabaseInfo.Port = "3306"
|
||||
LoginDatabaseInfo.Username = "username"
|
||||
LoginDatabaseInfo.Password = "password"
|
||||
LoginDatabaseInfo.Database = "auth"
|
||||
|
||||
#
|
||||
# DBQueryWorkerInterval
|
||||
# Description: Time (milliseconds) for Query Task Worker interval.
|
||||
# Default: 1000
|
||||
|
||||
DBQueryWorkerInterval = 1000
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
# UPDATE SETTINGS
|
||||
#
|
||||
# Updates.EnableDatabases
|
||||
# Description: A mask that describes which databases shall be updated.
|
||||
#
|
||||
# Following flags are available
|
||||
# DATABASE_LOGIN = 1, // Auth database
|
||||
#
|
||||
# Default: 0 - (All Disabled)
|
||||
# 1 - (All Enabled)
|
||||
|
||||
Updates.EnableDatabases = 0
|
||||
|
||||
#
|
||||
# Updates.SourcePath
|
||||
# Description: The path to your CypherCore source directory.
|
||||
# If the path is left empty, built-in CMAKE_SOURCE_DIR is used.
|
||||
# Example: "../CypherCore"
|
||||
# Default: ""
|
||||
|
||||
Updates.SourcePath = ""
|
||||
|
||||
#
|
||||
# Updates.AutoSetup
|
||||
# Description: Auto populate empty databases.
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
Updates.AutoSetup = 1
|
||||
|
||||
#
|
||||
# Updates.Redundancy
|
||||
# Description: Perform data redundancy checks through hashing
|
||||
# to detect changes on sql updates and reapply it.
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
Updates.Redundancy = 1
|
||||
|
||||
#
|
||||
# Updates.ArchivedRedundancy
|
||||
# Description: Check hashes of archived updates (slows down startup).
|
||||
# Default: 0 - (Disabled)
|
||||
# 1 - (Enabled)
|
||||
|
||||
Updates.ArchivedRedundancy = 0
|
||||
|
||||
#
|
||||
# Updates.AllowRehash
|
||||
# Description: Inserts the current file hash in the database if it is left empty.
|
||||
# Useful if you want to mark a file as applied but you don't know its hash.
|
||||
# Default: 1 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
|
||||
Updates.AllowRehash = 1
|
||||
|
||||
#
|
||||
# Updates.CleanDeadRefMaxCount
|
||||
# Description: Cleans dead/ orphaned references that occur if an update was removed or renamed and edited in one step.
|
||||
# It only starts the clean up if the count of the missing updates is below or equal the Updates.CleanDeadRefMaxCount value.
|
||||
# This way prevents erasing of the update history due to wrong source directory state (maybe wrong branch or bad revision).
|
||||
# Disable this if you want to know if the database is in a possible "dirty state".
|
||||
# Default: 3 - (Enabled)
|
||||
# 0 - (Disabled)
|
||||
# -1 - (Enabled - unlimited)
|
||||
|
||||
Updates.CleanDeadRefMaxCount = 3
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
###################################################################################################
|
||||
#
|
||||
# LOGGING SYSTEM SETTINGS
|
||||
#
|
||||
# Appender config values: Given a appender "name"
|
||||
# Appender.name
|
||||
# Description: Defines 'where to log'
|
||||
# Format: Type,LogLevel,Flags,optional1,optional2,optional3
|
||||
#
|
||||
# Type
|
||||
# 0 - (None)
|
||||
# 1 - (Console)
|
||||
# 2 - (File)
|
||||
# 3 - (DB)
|
||||
#
|
||||
# LogLevel
|
||||
# 0 - (Disabled)
|
||||
# 1 - (Trace)
|
||||
# 2 - (Debug)
|
||||
# 3 - (Info)
|
||||
# 4 - (Warn)
|
||||
# 5 - (Error)
|
||||
# 6 - (Fatal)
|
||||
#
|
||||
# Flags:
|
||||
# 0 - None
|
||||
# 1 - Prefix Timestamp to the text
|
||||
# 2 - Prefix Log Level to the text
|
||||
# 4 - Prefix Log Filter type to the text
|
||||
#
|
||||
# File: Name of the file (read as optional1 if Type = File)
|
||||
# Allows to use one "{0}" to create dynamic files
|
||||
#
|
||||
|
||||
Appender.Console=1,2,0
|
||||
Appender.Bnet=2,2,0,Bnet.log
|
||||
|
||||
# Logger config values: Given a logger "name"
|
||||
# Logger.name
|
||||
# Description: Defines 'What to log'
|
||||
# Format: LogLevel,AppenderList
|
||||
#
|
||||
# LogLevel
|
||||
# 0 - (Disabled)
|
||||
# 1 - (Trace)
|
||||
# 2 - (Debug)
|
||||
# 3 - (Info)
|
||||
# 4 - (Warn)
|
||||
# 5 - (Error)
|
||||
# 6 - (Fatal)
|
||||
#
|
||||
# AppenderList: List of appenders linked to logger
|
||||
# (Using spaces as separator).
|
||||
#
|
||||
|
||||
Logger.Server=3,Console Bnet
|
||||
Logger.Realmlist=3,Console Bnet
|
||||
Logger.Session=3,Console Bnet
|
||||
Logger.Network=3,Console Bnet
|
||||
Logger.SqlUpdates=3,Console Bnet
|
||||
Logger.ServiceProtobuf=2,Console Bnet
|
||||
|
||||
#
|
||||
###################################################################################################
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\default.props" />
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<StartupObject>BNetServer.Server</StartupObject>
|
||||
<ApplicationIcon>Red.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Framework\Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="BNetServer.conf.dist">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="BNetServer.pfx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using BNetServer.Services;
|
||||
|
||||
namespace BNetServer
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static RealmManager RealmMgr { get { return RealmManager.Instance; } }
|
||||
public static SessionManager SessionMgr { get { return SessionManager.Instance; } }
|
||||
public static ServiceDispatcher ServiceDispatcher { get { return ServiceDispatcher.Instance; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Configuration;
|
||||
using Framework.Rest;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace BNetServer
|
||||
{
|
||||
public class SessionManager : Singleton<SessionManager>
|
||||
{
|
||||
SessionManager()
|
||||
{
|
||||
_formInputs = new FormInputs();
|
||||
}
|
||||
|
||||
public bool Initialize()
|
||||
{
|
||||
int _port = ConfigMgr.GetDefaultValue("LoginREST.Port", 8081);
|
||||
if (_port < 0 || _port > 0xFFFF)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Specified login service port ({0}) out of allowed range (1-65535), defaulting to 8081", _port);
|
||||
_port = 8081;
|
||||
}
|
||||
|
||||
string configuredAddress = ConfigMgr.GetDefaultValue("LoginREST.ExternalAddress", "127.0.0.1");
|
||||
IPAddress address;
|
||||
if (!IPAddress.TryParse(configuredAddress, out address))
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Could not resolve LoginREST.ExternalAddress {0}", configuredAddress);
|
||||
return false;
|
||||
}
|
||||
_externalAddress = new IPEndPoint(address, _port);
|
||||
|
||||
configuredAddress = ConfigMgr.GetDefaultValue("LoginREST.LocalAddress", "127.0.0.1");
|
||||
if (!IPAddress.TryParse(configuredAddress, out address))
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Could not resolve LoginREST.ExternalAddress {0}", configuredAddress);
|
||||
return false;
|
||||
}
|
||||
|
||||
_localAddress = new IPEndPoint(address, _port);
|
||||
|
||||
// set up form inputs
|
||||
_formInputs.Type = "LOGIN_FORM";
|
||||
|
||||
var input = new FormInput();
|
||||
input.Id = "account_name";
|
||||
input.Type = "text";
|
||||
input.Label = "E-mail";
|
||||
input.MaxLength = 320;
|
||||
_formInputs.Inputs.Add(input);
|
||||
|
||||
input = new FormInput();
|
||||
input.Id = "password";
|
||||
input.Type = "password";
|
||||
input.Label = "Password";
|
||||
input.MaxLength = 16;
|
||||
_formInputs.Inputs.Add(input);
|
||||
|
||||
input = new FormInput();
|
||||
input.Id = "log_in_submit";
|
||||
input.Type = "submit";
|
||||
input.Label = "Log In";
|
||||
_formInputs.Inputs.Add(input);
|
||||
|
||||
_certificate = new X509Certificate2("BNetServer.pfx");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public IPEndPoint GetAddressForClient(IPAddress address)
|
||||
{
|
||||
if (IPAddress.IsLoopback(address))
|
||||
return _localAddress;
|
||||
|
||||
return _externalAddress;
|
||||
}
|
||||
|
||||
public FormInputs GetFormInput()
|
||||
{
|
||||
return _formInputs;
|
||||
}
|
||||
|
||||
public X509Certificate2 GetCertificate()
|
||||
{
|
||||
return _certificate;
|
||||
}
|
||||
|
||||
FormInputs _formInputs;
|
||||
IPEndPoint _externalAddress;
|
||||
IPEndPoint _localAddress;
|
||||
X509Certificate2 _certificate;
|
||||
}
|
||||
|
||||
public enum BanMode
|
||||
{
|
||||
Ip = 0,
|
||||
Account = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Framework.Configuration;
|
||||
using Framework.Database;
|
||||
using Framework.Networking;
|
||||
using Framework.Rest;
|
||||
using Framework.Serialization;
|
||||
using Framework.Web;
|
||||
using System;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
public class RestSession : SSLSocket
|
||||
{
|
||||
public RestSession(Socket socket) : base(socket) { }
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
AsyncHandshake(Global.SessionMgr.GetCertificate());
|
||||
}
|
||||
|
||||
public override void ReadHandler(int transferredBytes)
|
||||
{
|
||||
var httpRequest = HttpHelper.ParseRequest(GetReceiveBuffer(), transferredBytes);
|
||||
if (httpRequest == null)
|
||||
return;
|
||||
|
||||
switch (httpRequest.Method)
|
||||
{
|
||||
case "GET":
|
||||
default:
|
||||
HandleConnectRequest(httpRequest);
|
||||
break;
|
||||
case "POST":
|
||||
HandleLoginRequest(httpRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
AsyncRead();
|
||||
}
|
||||
|
||||
public void HandleConnectRequest(HttpHeader request)
|
||||
{
|
||||
// Login form is the same for all clients...
|
||||
SendResponse(HttpCode.Ok, Global.SessionMgr.GetFormInput());
|
||||
}
|
||||
|
||||
public void HandleLoginRequest(HttpHeader request)
|
||||
{
|
||||
LogonData loginForm = Json.CreateObject<LogonData>(request.Content);
|
||||
LogonResult loginResult = new LogonResult();
|
||||
if (loginForm == null)
|
||||
{
|
||||
loginResult.AuthenticationState = "LOGIN";
|
||||
loginResult.ErrorCode = "UNABLE_TO_DECODE";
|
||||
loginResult.ErrorMessage = "There was an internal error while connecting to Battle.net. Please try again later.";
|
||||
SendResponse(HttpCode.BadRequest, loginResult);
|
||||
return;
|
||||
}
|
||||
|
||||
string login = "";
|
||||
string password = "";
|
||||
|
||||
for (int i = 0; i < loginForm.Inputs.Count; ++i)
|
||||
{
|
||||
switch (loginForm.Inputs[i].Id)
|
||||
{
|
||||
case "account_name":
|
||||
login = loginForm.Inputs[i].Value;
|
||||
break;
|
||||
case "password":
|
||||
password = loginForm.Inputs[i].Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_AUTHENTICATION);
|
||||
stmt.AddValue(0, login);
|
||||
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
uint accountId = result.Read<uint>(0);
|
||||
string pass_hash = result.Read<string>(1);
|
||||
uint failedLogins = result.Read<uint>(2);
|
||||
string loginTicket = result.Read<string>(3);
|
||||
uint loginTicketExpiry = result.Read<uint>(4);
|
||||
bool isBanned = result.Read<ulong>(5) != 0;
|
||||
|
||||
if (CalculateShaPassHash(login, password) == pass_hash)
|
||||
{
|
||||
if (loginTicket.IsEmpty() || loginTicketExpiry < Time.UnixTime)
|
||||
{
|
||||
byte[] ticket = new byte[0].GenerateRandomKey(20);
|
||||
loginTicket = "TC-" + ticket.ToHexString();
|
||||
}
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_AUTHENTICATION);
|
||||
stmt.AddValue(0, loginTicket);
|
||||
stmt.AddValue(1, Time.UnixTime + 3600);
|
||||
stmt.AddValue(2, accountId);
|
||||
|
||||
DB.Login.Execute(stmt);
|
||||
loginResult.LoginTicket = loginTicket;
|
||||
}
|
||||
else if (!isBanned)
|
||||
{
|
||||
uint maxWrongPassword = ConfigMgr.GetDefaultValue("WrongPass.MaxCount", 0u);
|
||||
|
||||
if (ConfigMgr.GetDefaultValue("WrongPass.Logging", false))
|
||||
Log.outDebug(LogFilter.Network, "[{0}, Account {1}, Id {2}] Attempted to connect with wrong password!", request.Host, login, accountId);
|
||||
|
||||
if (maxWrongPassword != 0)
|
||||
{
|
||||
SQLTransaction trans = new SQLTransaction();
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_FAILED_LOGINS);
|
||||
stmt.AddValue(0, accountId);
|
||||
trans.Append(stmt);
|
||||
|
||||
++failedLogins;
|
||||
|
||||
Log.outDebug(LogFilter.Network, "MaxWrongPass : {0}, failed_login : {1}", maxWrongPassword, accountId);
|
||||
|
||||
if (failedLogins >= maxWrongPassword)
|
||||
{
|
||||
BanMode banType = ConfigMgr.GetDefaultValue("WrongPass.BanType", BanMode.Ip);
|
||||
int banTime = ConfigMgr.GetDefaultValue("WrongPass.BanTime", 600);
|
||||
|
||||
if (banType == BanMode.Account)
|
||||
{
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_BNET_ACCOUNT_AUTO_BANNED);
|
||||
stmt.AddValue(0, accountId);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.INS_IP_AUTO_BANNED);
|
||||
stmt.AddValue(0, request.Host);
|
||||
}
|
||||
|
||||
stmt.AddValue(1, banTime);
|
||||
trans.Append(stmt);
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_BNET_RESET_FAILED_LOGINS);
|
||||
stmt.AddValue(0, accountId);
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
DB.Login.CommitTransaction(trans);
|
||||
}
|
||||
}
|
||||
|
||||
loginResult.AuthenticationState = "DONE";
|
||||
SendResponse(HttpCode.Ok, loginResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
loginResult.AuthenticationState = "LOGIN";
|
||||
loginResult.ErrorCode = "UNABLE_TO_DECODE";
|
||||
loginResult.ErrorMessage = "There was an internal error while connecting to Battle.net. Please try again later.";
|
||||
SendResponse(HttpCode.BadRequest, loginResult);
|
||||
}
|
||||
}
|
||||
|
||||
void SendResponse<T>(HttpCode code, T response)
|
||||
{
|
||||
AsyncWrite(HttpHelper.CreateResponse(code, Json.CreateString(response)));
|
||||
}
|
||||
|
||||
string CalculateShaPassHash(string name, string password)
|
||||
{
|
||||
SHA256 sha256 = SHA256.Create();
|
||||
var i = sha256.ComputeHash(Encoding.UTF8.GetBytes(name));
|
||||
return sha256.ComputeHash(Encoding.UTF8.GetBytes(i.ToHexString() + ":" + password)).ToHexString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,707 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Challenge.V1;
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.IO;
|
||||
using Framework.Networking;
|
||||
using Framework.Rest;
|
||||
using Framework.Serialization;
|
||||
using Google.Protobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
public partial class Session : SSLSocket
|
||||
{
|
||||
public Session(Socket socket) : base(socket)
|
||||
{
|
||||
_accountInfo = new AccountInfo();
|
||||
|
||||
ClientRequestHandlers.Add("Command_RealmListTicketRequest_v1_b9", GetRealmListTicket);
|
||||
ClientRequestHandlers.Add("Command_LastCharPlayedRequest_v1_b9", GetLastCharPlayed);
|
||||
ClientRequestHandlers.Add("Command_RealmListRequest_v1_b9", GetRealmList);
|
||||
ClientRequestHandlers.Add("Command_RealmJoinRequest_v1_b9", JoinRealm);
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
string ip_address = GetRemoteIpAddress().ToString();
|
||||
Log.outTrace(LogFilter.Session, "{0} Accepted connection", GetClientInfo());
|
||||
|
||||
// Verify that this IP is not in the ip_banned table
|
||||
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS));
|
||||
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_IP_INFO);
|
||||
stmt.AddValue(0, ip_address);
|
||||
stmt.AddValue(1, BitConverter.ToUInt32(GetRemoteIpAddress().GetAddressBytes(), 0));
|
||||
|
||||
_queryProcessor.AddQuery(DB.Login.AsyncQuery(stmt).WithCallback(CheckIpCallback));
|
||||
}
|
||||
|
||||
void CheckIpCallback(SQLResult result)
|
||||
{
|
||||
if (!result.IsEmpty())
|
||||
{
|
||||
bool banned = false;
|
||||
do
|
||||
{
|
||||
if (result.Read<ulong>(0) != 0)
|
||||
banned = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Read<string>(1)))
|
||||
_ipCountry = result.Read<string>(1);
|
||||
|
||||
} while (result.NextRow());
|
||||
|
||||
if (banned)
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "{0} tries to log in using banned IP!", GetClientInfo());
|
||||
CloseSocket();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AsyncHandshake(Global.SessionMgr.GetCertificate());
|
||||
}
|
||||
|
||||
public override bool Update()
|
||||
{
|
||||
if (!base.Update())
|
||||
return false;
|
||||
|
||||
_queryProcessor.ProcessReadyQueries();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ReadHandler(int transferredBytes)
|
||||
{
|
||||
if (!IsOpen())
|
||||
return;
|
||||
|
||||
var stream = new CodedInputStream(GetReceiveBuffer(), 0, transferredBytes);
|
||||
while (!stream.IsAtEnd)
|
||||
{
|
||||
var header = new Header();
|
||||
stream.ReadMessage(header);
|
||||
|
||||
if (header.ServiceId != 0xFE)
|
||||
{
|
||||
Global.ServiceDispatcher.Dispatch(this, header.ServiceHash, header.Token, header.MethodId, stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
var handler = _responseCallbacks.LookupByKey(header.Token);
|
||||
if (handler != null)
|
||||
{
|
||||
handler(stream);
|
||||
_responseCallbacks.Remove(header.Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AsyncRead();
|
||||
}
|
||||
|
||||
void AsyncWrite(ByteBuffer packet)
|
||||
{
|
||||
if (!IsOpen())
|
||||
return;
|
||||
|
||||
AsyncWrite(packet.GetData());
|
||||
}
|
||||
|
||||
public void SendResponse(uint token, IMessage response)
|
||||
{
|
||||
Header header = new Header();
|
||||
header.Token = token;
|
||||
header.ServiceId = 0xFE;
|
||||
header.Size = (uint)response.CalculateSize();
|
||||
|
||||
var headerSizeBytes = BitConverter.GetBytes((ushort)header.CalculateSize());
|
||||
Array.Reverse(headerSizeBytes);
|
||||
|
||||
ByteBuffer packet = new ByteBuffer();
|
||||
packet.WriteBytes(headerSizeBytes, 2);
|
||||
packet.WriteBytes(header.ToByteArray());
|
||||
packet.WriteBytes(response.ToByteArray());
|
||||
|
||||
AsyncWrite(packet.GetData());
|
||||
}
|
||||
|
||||
public void SendResponse(uint token, BattlenetRpcErrorCode status)
|
||||
{
|
||||
Header header = new Header();
|
||||
header.Token = token;
|
||||
header.Status = (uint)status;
|
||||
header.ServiceId = 0xFE;
|
||||
|
||||
var headerSizeBytes = BitConverter.GetBytes((ushort)header.CalculateSize());
|
||||
Array.Reverse(headerSizeBytes);
|
||||
|
||||
ByteBuffer packet = new ByteBuffer();
|
||||
packet.WriteBytes(headerSizeBytes, 2);
|
||||
packet.WriteBytes(header.ToByteArray());
|
||||
|
||||
AsyncWrite(packet);
|
||||
}
|
||||
|
||||
public void SendRequest(uint serviceHash, uint methodId, IMessage request, Action<CodedInputStream> callback)
|
||||
{
|
||||
_responseCallbacks[_requestToken] = callback;
|
||||
SendRequest(serviceHash, methodId, request);
|
||||
}
|
||||
|
||||
public void SendRequest(uint serviceHash, uint methodId, IMessage request)
|
||||
{
|
||||
Header header = new Header();
|
||||
header.ServiceId = 0;
|
||||
header.ServiceHash = serviceHash;
|
||||
header.MethodId = methodId;
|
||||
header.Size = (uint)request.CalculateSize();
|
||||
header.Token = _requestToken++;
|
||||
|
||||
var headerSizeBytes = BitConverter.GetBytes((ushort)header.CalculateSize());
|
||||
Array.Reverse(headerSizeBytes);
|
||||
|
||||
ByteBuffer packet = new ByteBuffer();
|
||||
packet.WriteBytes(headerSizeBytes, 2);
|
||||
packet.WriteBytes(header.ToByteArray());
|
||||
packet.WriteBytes(request.ToByteArray());
|
||||
|
||||
AsyncWrite(packet);
|
||||
}
|
||||
|
||||
public BattlenetRpcErrorCode HandleLogon(Bgs.Protocol.Authentication.V1.LogonRequest logonRequest)
|
||||
{
|
||||
if (logonRequest.Program != "WoW")
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "Battlenet.LogonRequest: {0} attempted to log in with game other than WoW (using {1})!", GetClientInfo(), logonRequest.Program);
|
||||
return BattlenetRpcErrorCode.BadProgram;
|
||||
}
|
||||
|
||||
if (logonRequest.Platform != "Win" && logonRequest.Platform != "Wn64" && logonRequest.Platform != "Mc64")
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "Battlenet.LogonRequest: {0} attempted to log in from an unsupported platform (using {1})!", GetClientInfo(), logonRequest.Platform);
|
||||
return BattlenetRpcErrorCode.BadPlatform;
|
||||
}
|
||||
|
||||
if (logonRequest.Locale.ToEnum<LocaleConstant>() == LocaleConstant.enUS && logonRequest.Locale != "enUS")
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "Battlenet.LogonRequest: {0} attempted to log in with unsupported locale (using {1})!", GetClientInfo(), logonRequest.Locale);
|
||||
return BattlenetRpcErrorCode.BadLocale;
|
||||
}
|
||||
|
||||
_locale = logonRequest.Locale;
|
||||
_os = logonRequest.Platform;
|
||||
_build = (uint)logonRequest.ApplicationVersion;
|
||||
|
||||
var endpoint = Global.SessionMgr.GetAddressForClient(GetRemoteIpAddress());
|
||||
|
||||
ChallengeExternalRequest externalChallenge = new ChallengeExternalRequest();
|
||||
externalChallenge.PayloadType = "web_auth_url";
|
||||
|
||||
externalChallenge.Payload = ByteString.CopyFromUtf8(string.Format("https://{0}:{1}/bnetserver/login/", endpoint.Address, endpoint.Port));
|
||||
SendRequest((uint)OriginalHash.ChallengeListener, 3, externalChallenge);
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
|
||||
public BattlenetRpcErrorCode HandleVerifyWebCredentials(Bgs.Protocol.Authentication.V1.VerifyWebCredentialsRequest verifyWebCredentialsRequest)
|
||||
{
|
||||
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_ACCOUNT_INFO);
|
||||
stmt.AddValue(0, verifyWebCredentialsRequest.WebCredentials.ToStringUtf8());
|
||||
|
||||
SQLResult result = DB.Login.Query(stmt);
|
||||
if (result.IsEmpty())
|
||||
return BattlenetRpcErrorCode.Denied;
|
||||
|
||||
_accountInfo = new AccountInfo();
|
||||
_accountInfo.LoadResult(result);
|
||||
|
||||
if (_accountInfo.LoginTicketExpiry < Time.UnixTime)
|
||||
return BattlenetRpcErrorCode.TimedOut;
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_CHARACTER_COUNTS_BY_BNET_ID);
|
||||
stmt.AddValue(0, _accountInfo.Id);
|
||||
|
||||
SQLResult characterCountsResult = DB.Login.Query(stmt);
|
||||
if (!characterCountsResult.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
RealmHandle realmId = new RealmHandle(characterCountsResult.Read<byte>(3), characterCountsResult.Read<byte>(4), characterCountsResult.Read<uint>(2));
|
||||
_accountInfo.GameAccounts[characterCountsResult.Read<uint>(0)].CharacterCounts[realmId.GetAddress()] = characterCountsResult.Read<byte>(1);
|
||||
|
||||
} while (characterCountsResult.NextRow());
|
||||
}
|
||||
|
||||
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_LAST_PLAYER_CHARACTERS);
|
||||
stmt.AddValue(0, _accountInfo.Id);
|
||||
|
||||
SQLResult lastPlayerCharactersResult = DB.Login.Query(stmt);
|
||||
if (!lastPlayerCharactersResult.IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
RealmHandle realmId = new RealmHandle(lastPlayerCharactersResult.Read<byte>(1), lastPlayerCharactersResult.Read<byte>(2), lastPlayerCharactersResult.Read<uint>(3));
|
||||
|
||||
LastPlayedCharacterInfo lastPlayedCharacter = new LastPlayedCharacterInfo();
|
||||
lastPlayedCharacter.RealmId = realmId;
|
||||
lastPlayedCharacter.CharacterName = lastPlayerCharactersResult.Read<string>(4);
|
||||
lastPlayedCharacter.CharacterGUID = lastPlayerCharactersResult.Read<ulong>(5);
|
||||
lastPlayedCharacter.LastPlayedTime = lastPlayerCharactersResult.Read<uint>(6);
|
||||
|
||||
_accountInfo.GameAccounts[lastPlayerCharactersResult.Read<uint>(0)].LastPlayedCharacters[realmId.GetSubRegionAddress()] = lastPlayedCharacter;
|
||||
|
||||
} while (lastPlayerCharactersResult.NextRow());
|
||||
}
|
||||
|
||||
string ip_address = GetRemoteIpAddress().ToString();
|
||||
|
||||
// If the IP is 'locked', check that the player comes indeed from the correct IP address
|
||||
if (_accountInfo.IsLockedToIP)
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is locked to IP - '{1}' is logging in from '{2}'",
|
||||
_accountInfo.Login, _accountInfo.LastIP, ip_address);
|
||||
|
||||
if (_accountInfo.LastIP != ip_address)
|
||||
return BattlenetRpcErrorCode.RiskAccountLocked;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is not locked to ip", _accountInfo.Login);
|
||||
if (_accountInfo.LockCountry.IsEmpty() || _accountInfo.LockCountry == "00")
|
||||
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is not locked to country", _accountInfo.Login);
|
||||
else if (!_accountInfo.LockCountry.IsEmpty() && !_ipCountry.IsEmpty())
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "Session.HandleVerifyWebCredentials: Account '{0}' is locked to country: '{1}' Player country is '{2}'",
|
||||
_accountInfo.Login, _accountInfo.LockCountry, _ipCountry);
|
||||
|
||||
if (_ipCountry != _accountInfo.LockCountry)
|
||||
return BattlenetRpcErrorCode.RiskAccountLocked;
|
||||
}
|
||||
}
|
||||
|
||||
// If the account is banned, reject the logon attempt
|
||||
if (_accountInfo.IsBanned)
|
||||
{
|
||||
if (_accountInfo.IsPermanenetlyBanned)
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "{0} Session.HandleVerifyWebCredentials: Banned account {1} tried to login!", GetClientInfo(), _accountInfo.Login);
|
||||
return BattlenetRpcErrorCode.GameAccountBanned;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.outDebug(LogFilter.Session, "{0} Session.HandleVerifyWebCredentials: Temporarily banned account {1} tried to login!", GetClientInfo(), _accountInfo.Login);
|
||||
return BattlenetRpcErrorCode.GameAccountSuspended;
|
||||
}
|
||||
}
|
||||
|
||||
Bgs.Protocol.Authentication.V1.LogonResult logonResult = new Bgs.Protocol.Authentication.V1.LogonResult();
|
||||
logonResult.ErrorCode = 0;
|
||||
logonResult.AccountId = new EntityId();
|
||||
logonResult.AccountId.Low = _accountInfo.Id;
|
||||
logonResult.AccountId.High = 0x100000000000000;
|
||||
foreach (var pair in _accountInfo.GameAccounts)
|
||||
{
|
||||
if (!pair.Value.IsBanned)
|
||||
{
|
||||
EntityId gameAccountId = new EntityId();
|
||||
gameAccountId.Low = pair.Value.Id;
|
||||
gameAccountId.High = 0x200000200576F57;
|
||||
logonResult.GameAccountId.Add(gameAccountId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_ipCountry.IsEmpty())
|
||||
logonResult.GeoipCountry = _ipCountry;
|
||||
|
||||
logonResult.SessionKey = ByteString.CopyFrom(new byte[64].GenerateRandomKey(64));
|
||||
|
||||
_authed = true;
|
||||
|
||||
SendRequest((uint)OriginalHash.AuthenticationListener, 5, logonResult);
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
|
||||
public BattlenetRpcErrorCode HandleGetAccountState(Bgs.Protocol.Account.V1.GetAccountStateRequest request, Bgs.Protocol.Account.V1.GetAccountStateResponse response)
|
||||
{
|
||||
if (!_authed)
|
||||
return BattlenetRpcErrorCode.Denied;
|
||||
|
||||
if (request.Options.FieldPrivacyInfo)
|
||||
{
|
||||
response.State = new Bgs.Protocol.Account.V1.AccountState();
|
||||
response.State.PrivacyInfo = new Bgs.Protocol.Account.V1.PrivacyInfo();
|
||||
response.State.PrivacyInfo.IsUsingRid = false;
|
||||
response.State.PrivacyInfo.IsRealIdVisibleForViewFriends = false;
|
||||
response.State.PrivacyInfo.IsHiddenFromFriendFinder = true;
|
||||
|
||||
response.Tags = new Bgs.Protocol.Account.V1.AccountFieldTags();
|
||||
response.Tags.PrivacyInfoTag = 0xD7CA834D;
|
||||
}
|
||||
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
|
||||
public BattlenetRpcErrorCode HandleGetGameAccountState(Bgs.Protocol.Account.V1.GetGameAccountStateRequest request, Bgs.Protocol.Account.V1.GetGameAccountStateResponse response)
|
||||
{
|
||||
if (!_authed)
|
||||
return BattlenetRpcErrorCode.Denied;
|
||||
|
||||
if (request.Options.FieldGameLevelInfo)
|
||||
{
|
||||
var gameAccountInfo = _accountInfo.GameAccounts.LookupByKey(request.GameAccountId.Low);
|
||||
if (gameAccountInfo != null)
|
||||
{
|
||||
response.State = new Bgs.Protocol.Account.V1.GameAccountState();
|
||||
response.State.GameLevelInfo = new Bgs.Protocol.Account.V1.GameLevelInfo();
|
||||
response.State.GameLevelInfo.Name = gameAccountInfo.DisplayName;
|
||||
response.State.GameLevelInfo.Program = 5730135; // WoW
|
||||
}
|
||||
|
||||
response.Tags = new Bgs.Protocol.Account.V1.GameAccountFieldTags();
|
||||
response.Tags.GameLevelInfoTag = 0x5C46D483;
|
||||
}
|
||||
|
||||
if (request.Options.FieldGameStatus)
|
||||
{
|
||||
if (response.State == null)
|
||||
response.State = new Bgs.Protocol.Account.V1.GameAccountState();
|
||||
|
||||
response.State.GameStatus = new Bgs.Protocol.Account.V1.GameStatus();
|
||||
|
||||
var gameAccountInfo = _accountInfo.GameAccounts.LookupByKey(request.GameAccountId.Low);
|
||||
if (gameAccountInfo != null)
|
||||
{
|
||||
response.State.GameStatus.IsSuspended = gameAccountInfo.IsBanned;
|
||||
response.State.GameStatus.IsBanned = gameAccountInfo.IsPermanenetlyBanned;
|
||||
}
|
||||
|
||||
response.State.GameStatus.Program = 5730135; // WoW
|
||||
response.Tags.GameStatusTag = 0x98B75F99;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Variant GetParam(Dictionary<string, Variant> Params, string paramName)
|
||||
{
|
||||
return Params.LookupByKey(paramName);
|
||||
}
|
||||
|
||||
delegate BattlenetRpcErrorCode ClientRequestHandler(Dictionary<string, Variant> Params, Bgs.Protocol.GameUtilities.V1.ClientResponse response);
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 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 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;
|
||||
}
|
||||
|
||||
public BattlenetRpcErrorCode HandleGetAllValuesForAttribute(Bgs.Protocol.GameUtilities.V1.GetAllValuesForAttributeRequest request, Bgs.Protocol.GameUtilities.V1.GetAllValuesForAttributeResponse response)
|
||||
{
|
||||
if (!_authed)
|
||||
return BattlenetRpcErrorCode.Denied;
|
||||
|
||||
if (request.AttributeKey == "Command_RealmListRequest_v1_b9")
|
||||
{
|
||||
Global.RealmMgr.WriteSubRegions(response);
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
public string GetClientInfo()
|
||||
{
|
||||
string stream = '[' + GetRemoteIpAddress().ToString() + ':' + GetRemotePort();
|
||||
if (_accountInfo != null && !string.IsNullOrEmpty(_accountInfo.Login))
|
||||
stream += ", Account: " + _accountInfo.Login;
|
||||
|
||||
if (_gameAccountInfo != null)
|
||||
stream += ", Game account: " + _gameAccountInfo.Name;
|
||||
|
||||
stream += ']';
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
public uint GetAccountId() { return _accountInfo.Id; }
|
||||
public uint GetGameAccountId() { return _gameAccountInfo.Id; }
|
||||
|
||||
Dictionary<string, ClientRequestHandler> ClientRequestHandlers = new Dictionary<string, ClientRequestHandler>();
|
||||
|
||||
AccountInfo _accountInfo;
|
||||
GameAccountInfo _gameAccountInfo; // Points at selected game account (inside _gameAccounts)
|
||||
|
||||
string _locale;
|
||||
string _os;
|
||||
uint _build;
|
||||
|
||||
string _ipCountry;
|
||||
|
||||
Array<byte> _clientSecret = new Array<byte>(32);
|
||||
|
||||
bool _authed;
|
||||
|
||||
QueryCallbackProcessor _queryProcessor = new QueryCallbackProcessor();
|
||||
|
||||
Dictionary<uint, Action<CodedInputStream>> _responseCallbacks = new Dictionary<uint, Action<CodedInputStream>>();
|
||||
uint _requestToken;
|
||||
}
|
||||
|
||||
public class AccountInfo
|
||||
{
|
||||
public void LoadResult(SQLResult result)
|
||||
{
|
||||
Id = result.Read<uint>(0);
|
||||
Login = result.Read<string>(1);
|
||||
IsLockedToIP = result.Read<bool>(2);
|
||||
LockCountry = result.Read<string>(3);
|
||||
LastIP = result.Read<string>(4);
|
||||
LoginTicketExpiry = result.Read<uint>(5);
|
||||
IsBanned = result.Read<ulong>(6) != 0;
|
||||
IsPermanenetlyBanned = result.Read<ulong>(7) != 0;
|
||||
PasswordVerifier = result.Read<string>(9);
|
||||
Salt = result.Read<string>(10);
|
||||
|
||||
const int GameAccountFieldsOffset = 8;
|
||||
do
|
||||
{
|
||||
var account = new GameAccountInfo();
|
||||
account.LoadResult(result.GetFields(), GameAccountFieldsOffset);
|
||||
GameAccounts[result.Read<uint>(GameAccountFieldsOffset)] = account;
|
||||
|
||||
} while (result.NextRow());
|
||||
|
||||
}
|
||||
|
||||
public uint Id;
|
||||
public string Login;
|
||||
public bool IsLockedToIP;
|
||||
public string LockCountry;
|
||||
public string LastIP;
|
||||
public uint LoginTicketExpiry;
|
||||
public bool IsBanned;
|
||||
public bool IsPermanenetlyBanned;
|
||||
public string PasswordVerifier;
|
||||
public string Salt;
|
||||
|
||||
public Dictionary<uint, GameAccountInfo> GameAccounts = new Dictionary<uint, GameAccountInfo>();
|
||||
}
|
||||
|
||||
public class GameAccountInfo
|
||||
{
|
||||
public void LoadResult(SQLFields fields, int startColumn)
|
||||
{
|
||||
Id = fields.Read<uint>(startColumn + 0);
|
||||
Name = fields.Read<string>(startColumn + 1);
|
||||
IsBanned = fields.Read<ulong>(startColumn + 2) != 0;
|
||||
IsPermanenetlyBanned = fields.Read<ulong>(startColumn + 3) != 0;
|
||||
SecurityLevel = (AccountTypes)fields.Read<byte>(startColumn + 4);
|
||||
|
||||
int hashPos = Name.IndexOf('#');
|
||||
if (hashPos != -1)
|
||||
DisplayName = "WoW" + Name.Substring(hashPos + 1);
|
||||
else
|
||||
DisplayName = Name;
|
||||
}
|
||||
|
||||
public uint Id;
|
||||
public string Name;
|
||||
public string DisplayName;
|
||||
public bool IsBanned;
|
||||
public bool IsPermanenetlyBanned;
|
||||
public AccountTypes SecurityLevel;
|
||||
|
||||
public Dictionary<uint /*realmAddress*/, byte> CharacterCounts = new Dictionary<uint, byte>();
|
||||
public Dictionary<string /*subRegion*/, LastPlayedCharacterInfo> LastPlayedCharacters = new Dictionary<string, LastPlayedCharacterInfo>();
|
||||
}
|
||||
|
||||
public class LastPlayedCharacterInfo
|
||||
{
|
||||
public RealmHandle RealmId;
|
||||
public string CharacterName;
|
||||
public ulong CharacterGUID;
|
||||
public uint LastPlayedTime;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using BNetServer.Networking;
|
||||
using Framework.Configuration;
|
||||
using Framework.Database;
|
||||
using Framework.Networking;
|
||||
using System;
|
||||
using System.Timers;
|
||||
|
||||
namespace BNetServer
|
||||
{
|
||||
class Server
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Console.CancelKeyPress += (o, e) =>
|
||||
{
|
||||
Global.RealmMgr.Close();
|
||||
|
||||
Log.outInfo(LogFilter.Server, "Halting process...");
|
||||
Environment.Exit(-1);
|
||||
};
|
||||
|
||||
if (!ConfigMgr.Load(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".conf"))
|
||||
ExitNow();
|
||||
|
||||
// Initialize the database connection
|
||||
if (!StartDB())
|
||||
ExitNow();
|
||||
|
||||
string bindIp = ConfigMgr.GetDefaultValue("BindIP", "0.0.0.0");
|
||||
|
||||
var restSocketServer = new SocketManager<RestSession>();
|
||||
int restPort = ConfigMgr.GetDefaultValue("LoginREST.Port", 8081);
|
||||
if (restPort < 0 || restPort > 0xFFFF)
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Specified login service port ({0}) out of allowed range (1-65535), defaulting to 8081", restPort);
|
||||
restPort = 8081;
|
||||
}
|
||||
|
||||
if (!restSocketServer.StartNetwork(bindIp, restPort))
|
||||
{
|
||||
Log.outError(LogFilter.Server, "Failed to initialize Rest Socket Server");
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
// Get the list of realms for the server
|
||||
Global.RealmMgr.Initialize(ConfigMgr.GetDefaultValue("RealmsStateUpdateDelay", 10));
|
||||
Global.SessionMgr.Initialize();
|
||||
|
||||
var sessionSocketServer = new SocketManager<Session>();
|
||||
// Start the listening port (acceptor) for auth connections
|
||||
int bnPort = ConfigMgr.GetDefaultValue("BattlenetPort", 1119);
|
||||
if (bnPort < 0 || bnPort > 0xFFFF)
|
||||
{
|
||||
Log.outError(LogFilter.Server, "Specified battle.net port ({0}) out of allowed range (1-65535)", bnPort);
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
if (!sessionSocketServer.StartNetwork(bindIp, bnPort))
|
||||
{
|
||||
Log.outError(LogFilter.Network, "Failed to start BnetServer Network");
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
uint _banExpiryCheckInterval = ConfigMgr.GetDefaultValue("BanExpiryCheckInterval", 60u);
|
||||
_banExpiryCheckTimer = new Timer(_banExpiryCheckInterval);
|
||||
_banExpiryCheckTimer.Elapsed += _banExpiryCheckTimer_Elapsed;
|
||||
|
||||
while (true) ;
|
||||
}
|
||||
|
||||
static bool StartDB()
|
||||
{
|
||||
DatabaseLoader loader = new DatabaseLoader(DatabaseTypeFlags.None);
|
||||
loader.AddDatabase(DB.Login, "Login");
|
||||
|
||||
if (!loader.Load())
|
||||
return false;
|
||||
|
||||
Log.SetRealmId(0); // Enables DB appenders when realm is set.
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ExitNow()
|
||||
{
|
||||
Log.outInfo(LogFilter.Server, "Halting process...");
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
static void _banExpiryCheckTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS));
|
||||
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.UPD_EXPIRED_ACCOUNT_BANS));
|
||||
DB.Login.Execute(DB.Login.GetPreparedStatement(LoginStatements.DEL_BNET_EXPIRED_ACCOUNT_BANNED));
|
||||
}
|
||||
|
||||
static Timer _banExpiryCheckTimer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,582 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Account.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class AccountService : ServiceBase
|
||||
{
|
||||
public AccountService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 12:
|
||||
{
|
||||
GameAccountHandle request = new GameAccountHandle();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GameAccountBlob response = new GameAccountBlob();
|
||||
BattlenetRpcErrorCode status = HandleGetGameAccountBlob(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameAccountBlob(GameAccountHandle: {1}) returned GameAccountBlob: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
{
|
||||
GetAccountRequest request = new GetAccountRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetAccountResponse response = new GetAccountResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetAccount(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetAccount(GetAccountRequest: {1}) returned GetAccountResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 14:
|
||||
{
|
||||
CreateGameAccountRequest request = new CreateGameAccountRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GameAccountHandle response = new GameAccountHandle();
|
||||
BattlenetRpcErrorCode status = HandleCreateGameAccount(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.CreateGameAccount(CreateGameAccountRequest: {1}) returned GameAccountHandle: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
IsIgrAddressRequest request = new IsIgrAddressRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleIsIgrAddress(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.IsIgrAddress(IsIgrAddressRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 20:
|
||||
{
|
||||
CacheExpireRequest request = new CacheExpireRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleCacheExpire(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.CacheExpire(CacheExpireRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
{
|
||||
CredentialUpdateRequest request = new CredentialUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
CredentialUpdateResponse response = new CredentialUpdateResponse();
|
||||
BattlenetRpcErrorCode status = HandleCredentialUpdate(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.CredentialUpdate(CredentialUpdateRequest: {1}) returned CredentialUpdateResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 25:
|
||||
{
|
||||
SubscriptionUpdateRequest request = new SubscriptionUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
SubscriptionUpdateResponse response = new SubscriptionUpdateResponse();
|
||||
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.Subscribe(SubscriptionUpdateRequest: {1}) returned SubscriptionUpdateResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 26:
|
||||
{
|
||||
SubscriptionUpdateRequest request = new SubscriptionUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.Unsubscribe(SubscriptionUpdateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 30:
|
||||
{
|
||||
GetAccountStateRequest request = new GetAccountStateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetAccountStateResponse response = new GetAccountStateResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetAccountState(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetAccountState(GetAccountStateRequest: {1}) returned GetAccountStateResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
{
|
||||
GetGameAccountStateRequest request = new GetGameAccountStateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetGameAccountStateResponse response = new GetGameAccountStateResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetGameAccountState(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameAccountState(GetGameAccountStateRequest: {1}) returned GetGameAccountStateResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
GetLicensesRequest request = new GetLicensesRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetLicensesResponse response = new GetLicensesResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetLicenses(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetLicenses(GetLicensesRequest: {1}) returned GetLicensesResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 33:
|
||||
{
|
||||
GetGameTimeRemainingInfoRequest request = new GetGameTimeRemainingInfoRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetGameTimeRemainingInfoResponse response = new GetGameTimeRemainingInfoResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetGameTimeRemainingInfo(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameTimeRemainingInfo(GetGameTimeRemainingInfoRequest: {1}) returned GetGameTimeRemainingInfoResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 34:
|
||||
{
|
||||
GetGameSessionInfoRequest request = new GetGameSessionInfoRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetGameSessionInfoResponse response = new GetGameSessionInfoResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetGameSessionInfo(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameSessionInfo(GetGameSessionInfoRequest: {1}) returned GetGameSessionInfoResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 35:
|
||||
{
|
||||
GetCAISInfoRequest request = new GetCAISInfoRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetCAISInfoResponse response = new GetCAISInfoResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetCAISInfo(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetCAISInfo(GetCAISInfoRequest: {1}) returned GetCAISInfoResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 36:
|
||||
{
|
||||
ForwardCacheExpireRequest request = new ForwardCacheExpireRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleForwardCacheExpire(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.ForwardCacheExpire(ForwardCacheExpireRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 37:
|
||||
{
|
||||
GetAuthorizedDataRequest request = new GetAuthorizedDataRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetAuthorizedDataResponse response = new GetAuthorizedDataResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetAuthorizedData(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetAuthorizedData(GetAuthorizedDataRequest: {1}) returned GetAuthorizedDataResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 38:
|
||||
{
|
||||
AccountFlagUpdateRequest request = new AccountFlagUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleAccountFlagUpdate(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.AccountFlagUpdate(AccountFlagUpdateRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 39:
|
||||
{
|
||||
GameAccountFlagUpdateRequest request = new GameAccountFlagUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleGameAccountFlagUpdate(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GameAccountFlagUpdate(GameAccountFlagUpdateRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
/* case 40:
|
||||
{
|
||||
UpdateParentalControlsAndCAISRequest request = new UpdateParentalControlsAndCAISRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUpdateParentalControlsAndCAIS(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.UpdateParentalControlsAndCAIS(UpdateParentalControlsAndCAISRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 41:
|
||||
{
|
||||
CreateGameAccountRequest request = new CreateGameAccountRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
CreateGameAccountResponse response = new CreateGameAccountResponse();
|
||||
BattlenetRpcErrorCode status = HandleCreateGameAccount2(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.CreateGameAccount2(CreateGameAccountRequest: {1}) returned CreateGameAccountResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 42:
|
||||
{
|
||||
GetGameAccountRequest request = new GetGameAccountRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
GetGameAccountResponse response = new GetGameAccountResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetGameAccount(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.GetGameAccount(GetGameAccountRequest: {1}) returned GetGameAccountResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, &response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 43:
|
||||
{
|
||||
QueueDeductRecordRequest request = new QueueDeductRecordRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleQueueDeductRecord(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountService.QueueDeductRecord(QueueDeductRecordRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}*/
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetGameAccountBlob(GameAccountHandle request, GameAccountBlob response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetAccount({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetAccount(GetAccountRequest request, GetAccountResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetAccount({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleCreateGameAccount(CreateGameAccountRequest request, GameAccountHandle response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.CreateGameAccount({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleIsIgrAddress(IsIgrAddressRequest request, NoData response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.IsIgrAddress({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleCacheExpire(CacheExpireRequest request)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.CacheExpire({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleCredentialUpdate(CredentialUpdateRequest request, CredentialUpdateResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.CredentialUpdate({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSubscribe(SubscriptionUpdateRequest request, SubscriptionUpdateResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.Subscribe({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUnsubscribe(SubscriptionUpdateRequest request, NoData response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.Unsubscribe({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetAccountState(GetAccountStateRequest request, GetAccountStateResponse response)
|
||||
{
|
||||
return _session.HandleGetAccountState(request, response);
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetGameAccountState(GetGameAccountStateRequest request, GetGameAccountStateResponse response)
|
||||
{
|
||||
return _session.HandleGetGameAccountState(request, response);
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetLicenses(GetLicensesRequest request, GetLicensesResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetLicenses({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetGameTimeRemainingInfo(GetGameTimeRemainingInfoRequest request, GetGameTimeRemainingInfoResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetGameTimeRemainingInfo({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetGameSessionInfo(GetGameSessionInfoRequest request, GetGameSessionInfoResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetGameSessionInfo({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetCAISInfo(GetCAISInfoRequest request, GetCAISInfoResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetCAISInfo({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleForwardCacheExpire(ForwardCacheExpireRequest request, NoData response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.ForwardCacheExpire({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetAuthorizedData(GetAuthorizedDataRequest request, GetAuthorizedDataResponse response)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetAuthorizedData({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleAccountFlagUpdate(AccountFlagUpdateRequest request)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.AccountFlagUpdate({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGameAccountFlagUpdate(GameAccountFlagUpdateRequest request)
|
||||
{
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GameAccountFlagUpdate({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
/*BattlenetRpcErrorCode HandleUpdateParentalControlsAndCAIS(UpdateParentalControlsAndCAISRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.UpdateParentalControlsAndCAIS: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleCreateGameAccount2(CreateGameAccountRequest request, CreateGameAccountResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.CreateGameAccount2: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetGameAccount(GetGameAccountRequest request, GetGameAccountResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.GetGameAccount: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleQueueDeductRecord(QueueDeductRecordRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountService.QueueDeductRecord: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class AccountListener : ServiceBase
|
||||
{
|
||||
public AccountListener(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
AccountStateNotification request = new AccountStateNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnAccountStateUpdated(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnAccountStateUpdated(AccountStateNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
GameAccountStateNotification request = new GameAccountStateNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnGameAccountStateUpdated(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnGameAccountStateUpdated(GameAccountStateNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
GameAccountNotification request = new GameAccountNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnGameAccountsUpdated(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnGameAccountsUpdated(GameAccountNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
GameAccountSessionNotification request = new GameAccountSessionNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnGameSessionUpdated(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AccountListener.OnGameSessionUpdated(GameAccountSessionNotification: {1} status: {2}.", GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnAccountStateUpdated(AccountStateNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnAccountStateUpdated: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnGameAccountStateUpdated(GameAccountStateNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnGameAccountStateUpdated: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnGameAccountsUpdated(GameAccountNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnGameAccountsUpdated: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnGameSessionUpdated(GameAccountSessionNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AccountListener.OnGameSessionUpdated: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Authentication.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class AuthenticationService : ServiceBase
|
||||
{
|
||||
public AuthenticationService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
LogonRequest request = new LogonRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleLogon(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.Logon(bgs.protocol.authentication.v1.LogonRequest: {1}) returned bgs.protocol.NoData: {2} status {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ModuleNotification request = new ModuleNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleModuleNotify(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleNotify(bgs.protocol.authentication.v1.ModuleNotification: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ModuleMessageRequest request = new ModuleMessageRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleModuleMessage(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.ModuleMessage(bgs.protocol.authentication.v1.ModuleMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
EntityId request = new EntityId();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSelectGameAccount_DEPRECATED(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount_DEPRECATED(bgs.protocol.EntityId: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
GenerateSSOTokenRequest request = new GenerateSSOTokenRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GenerateSSOTokenResponse response = new GenerateSSOTokenResponse();
|
||||
BattlenetRpcErrorCode status = HandleGenerateSSOToken(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateSSOToken(bgs.protocol.authentication.v1.GenerateSSOTokenRequest: {1}) returned bgs.protocol.authentication.v1.GenerateSSOTokenResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
SelectGameAccountRequest request = new SelectGameAccountRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSelectGameAccount(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.SelectGameAccount(bgs.protocol.authentication.v1.SelectGameAccountRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
VerifyWebCredentialsRequest request = new VerifyWebCredentialsRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleVerifyWebCredentials(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.VerifyWebCredentials(bgs.protocol.authentication.v1.VerifyWebCredentialsRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
GenerateWebCredentialsRequest request = new GenerateWebCredentialsRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GenerateWebCredentialsResponse response = new GenerateWebCredentialsResponse();
|
||||
BattlenetRpcErrorCode status = HandleGenerateWebCredentials(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationService.GenerateWebCredentials(bgs.protocol.authentication.v1.GenerateWebCredentialsRequest: {1}) returned bgs.protocol.authentication.v1.GenerateWebCredentialsResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleLogon(LogonRequest request, NoData response)
|
||||
{
|
||||
return _session.HandleLogon(request);
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleModuleNotify(ModuleNotification request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.ModuleNotify: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleModuleMessage(ModuleMessageRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.ModuleMessage: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSelectGameAccount_DEPRECATED(EntityId request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.SelectGameAccount_DEPRECATED: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGenerateSSOToken(GenerateSSOTokenRequest request, GenerateSSOTokenResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.GenerateSSOToken: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSelectGameAccount(SelectGameAccountRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.SelectGameAccount: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleVerifyWebCredentials(VerifyWebCredentialsRequest request, NoData response)
|
||||
{
|
||||
return _session.HandleVerifyWebCredentials(request);
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGenerateWebCredentials(GenerateWebCredentialsRequest request, GenerateWebCredentialsResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationService.GenerateWebCredentials: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
|
||||
class AuthenticationListener : ServiceBase
|
||||
{
|
||||
public AuthenticationListener(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ModuleLoadRequest request = new ModuleLoadRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnModuleLoad(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnModuleLoad(bgs.protocol.authentication.v1.ModuleLoadRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ModuleMessageRequest request = new ModuleMessageRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleOnModuleMessage(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnModuleMessage(bgs.protocol.authentication.v1.ModuleMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
ServerStateChangeRequest request = new ServerStateChangeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnServerStateChange(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnServerStateChange(bgs.protocol.authentication.v1.ServerStateChangeRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
LogonResult request = new LogonResult();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnLogonComplete(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonComplete(bgs.protocol.authentication.v1.LogonResult: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
MemModuleLoadRequest request = new MemModuleLoadRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
MemModuleLoadResponse response = new MemModuleLoadResponse();
|
||||
BattlenetRpcErrorCode status = HandleOnMemModuleLoad(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnMemModuleLoad(bgs.protocol.authentication.v1.MemModuleLoadRequest: {1}) returned bgs.protocol.authentication.v1.MemModuleLoadResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
LogonUpdateRequest request = new LogonUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnLogonUpdate(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonUpdate(bgs.protocol.authentication.v1.LogonUpdateRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
{
|
||||
VersionInfoNotification request = new VersionInfoNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnVersionInfoUpdated(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnVersionInfoUpdated(bgs.protocol.authentication.v1.VersionInfoNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
{
|
||||
LogonQueueUpdateRequest request = new LogonQueueUpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnLogonQueueUpdate(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonQueueUpdate(bgs.protocol.authentication.v1.LogonQueueUpdateRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
{
|
||||
NoData request = new NoData();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnLogonQueueEnd(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnLogonQueueEnd(bgs.protocol.NoData: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 14:
|
||||
{
|
||||
GameAccountSelectedRequest request = new GameAccountSelectedRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnGameAccountSelected(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method AuthenticationListener.OnGameAccountSelected(bgs.protocol.authentication.v1.GameAccountSelectedRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnModuleLoad(ModuleLoadRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnModuleLoad: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnModuleMessage(ModuleMessageRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnModuleMessage: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnServerStateChange(ServerStateChangeRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnServerStateChange: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnLogonComplete(LogonResult request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonComplete: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnMemModuleLoad(MemModuleLoadRequest request, MemModuleLoadResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnMemModuleLoad: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnLogonUpdate(LogonUpdateRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonUpdate: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnVersionInfoUpdated(VersionInfoNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnVersionInfoUpdated: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnLogonQueueUpdate(LogonQueueUpdateRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonQueueUpdate: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnLogonQueueEnd(NoData request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnLogonQueueEnd: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnGameAccountSelected(GameAccountSelectedRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method AuthenticationListener.OnGameAccountSelected: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Challenge.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class ChallengeService : ServiceBase
|
||||
{
|
||||
public ChallengeService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ChallengePickedRequest request = new ChallengePickedRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
ChallengePickedResponse response = new ChallengePickedResponse();
|
||||
BattlenetRpcErrorCode status = HandleChallengePicked(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.ChallengePicked(bgs.protocol.challenge.v1.ChallengePickedRequest: {1}) returned bgs.protocol.challenge.v1.ChallengePickedResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ChallengeAnsweredRequest request = new ChallengeAnsweredRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
ChallengeAnsweredResponse response = new ChallengeAnsweredResponse();
|
||||
BattlenetRpcErrorCode status = HandleChallengeAnswered(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.ChallengeAnswered(bgs.protocol.challenge.v1.ChallengeAnsweredRequest: {1}) returned bgs.protocol.challenge.v1.ChallengeAnsweredResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ChallengeCancelledRequest request = new ChallengeCancelledRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleChallengeCancelled(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.ChallengeCancelled(bgs.protocol.challenge.v1.ChallengeCancelledRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
SendChallengeToUserRequest request = new SendChallengeToUserRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
SendChallengeToUserResponse response = new SendChallengeToUserResponse();
|
||||
BattlenetRpcErrorCode status = HandleSendChallengeToUser(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeService.SendChallengeToUser(bgs.protocol.challenge.v1.SendChallengeToUserRequest: {1}) returned bgs.protocol.challenge.v1.SendChallengeToUserResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleChallengePicked(ChallengePickedRequest request, ChallengePickedResponse response) {
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeService.ChallengePicked: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleChallengeAnswered(ChallengeAnsweredRequest request, ChallengeAnsweredResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeService.ChallengeAnswered: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleChallengeCancelled(ChallengeCancelledRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeService.ChallengeCancelled: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSendChallengeToUser(SendChallengeToUserRequest request, SendChallengeToUserResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeService.SendChallengeToUser: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ChallengeListener : ServiceBase
|
||||
{
|
||||
public ChallengeListener(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ChallengeUserRequest request = new ChallengeUserRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnChallengeUser(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeListener.OnChallengeUser(bgs.protocol.challenge.v1.ChallengeUserRequest: {1} status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
ChallengeResultRequest request = new ChallengeResultRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnChallengeResult(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeListener.OnChallengeResult(bgs.protocol.challenge.v1.ChallengeResultRequest: {1} status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
ChallengeExternalRequest request = new ChallengeExternalRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnExternalChallenge(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeListener.OnExternalChallenge(bgs.protocol.challenge.v1.ChallengeExternalRequest: {1} status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
ChallengeExternalResult request = new ChallengeExternalResult();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnExternalChallengeResult(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChallengeListener.OnExternalChallengeResult(bgs.protocol.challenge.v1.ChallengeExternalResult: {1} status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnChallengeUser(ChallengeUserRequest request) {
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeListener.OnChallengeUser: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnChallengeResult(ChallengeResultRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeListener.OnChallengeResult: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnExternalChallenge(ChallengeExternalRequest request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeListener.OnExternalChallenge: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnExternalChallengeResult(ChallengeExternalResult request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChallengeListener.OnExternalChallengeResult: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Channel.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class ChannelService : ServiceBase
|
||||
{
|
||||
public ChannelService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
RemoveMemberRequest request = new RemoveMemberRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleRemoveMember(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelService.RemoveMember(bgs.protocol.channel.v1.RemoveMemberRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
SendMessageRequest request = new SendMessageRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSendMessage(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelService.SendMessage(bgs.protocol.channel.v1.SendMessageRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
UpdateChannelStateRequest request = new UpdateChannelStateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUpdateChannelState(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelService.UpdateChannelState(bgs.protocol.channel.v1.UpdateChannelStateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
UpdateMemberStateRequest request = new UpdateMemberStateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUpdateMemberState(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelService.UpdateMemberState(bgs.protocol.channel.v1.UpdateMemberStateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
DissolveRequest request = new DissolveRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleDissolve(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelService.Dissolve(bgs.protocol.channel.v1.DissolveRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleRemoveMember(RemoveMemberRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelService.RemoveMember: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSendMessage(SendMessageRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelService.SendMessage: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUpdateChannelState(UpdateChannelStateRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelService.UpdateChannelState: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUpdateMemberState(UpdateMemberStateRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelService.UpdateMemberState: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleDissolve(DissolveRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelService.Dissolve: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
|
||||
class ChannelListener : ServiceBase
|
||||
{
|
||||
public ChannelListener(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
JoinNotification request = new JoinNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnJoin(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnJoin(bgs.protocol.channel.v1.JoinNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
MemberAddedNotification request = new MemberAddedNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnMemberAdded(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnMemberAdded(bgs.protocol.channel.v1.MemberAddedNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
LeaveNotification request = new LeaveNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnLeave(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnLeave(bgs.protocol.channel.v1.LeaveNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
MemberRemovedNotification request = new MemberRemovedNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnMemberRemoved(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnMemberRemoved(bgs.protocol.channel.v1.MemberRemovedNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
SendMessageNotification request = new SendMessageNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnSendMessage(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnSendMessage(bgs.protocol.channel.v1.SendMessageNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
UpdateChannelStateNotification request = new UpdateChannelStateNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnUpdateChannelState(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnUpdateChannelState(bgs.protocol.channel.v1.UpdateChannelStateNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
UpdateMemberStateNotification request = new UpdateMemberStateNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnUpdateMemberState(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ChannelListener.OnUpdateMemberState(bgs.protocol.channel.v1.UpdateMemberStateNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnJoin(JoinNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnJoin: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnMemberAdded(MemberAddedNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnMemberAdded: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnLeave(LeaveNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnLeave: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnMemberRemoved(MemberRemovedNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnMemberRemoved: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnSendMessage(SendMessageNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnSendMessage: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnUpdateChannelState(UpdateChannelStateNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnUpdateChannelState: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnUpdateMemberState(UpdateMemberStateNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ChannelListener.OnUpdateMemberState: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Connection.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class ConnectionService : ServiceBase
|
||||
{
|
||||
public ConnectionService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ConnectRequest request = ConnectRequest.Parser.ParseFrom(stream);
|
||||
ConnectResponse response = new ConnectResponse();
|
||||
|
||||
BattlenetRpcErrorCode status = HandleConnect(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Connect(bgs.protocol.connection.v1.ConnectRequest: {1}) returned bgs.protocol.connection.v1.ConnectResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
BindRequest request = new BindRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
BindResponse response = new BindResponse();
|
||||
BattlenetRpcErrorCode status = HandleBind(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Bind(bgs.protocol.connection.v1.BindRequest: {1}) returned bgs.protocol.connection.v1.BindResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
EchoRequest request = new EchoRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
EchoResponse response = new EchoResponse();
|
||||
BattlenetRpcErrorCode status = HandleEcho(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Echo(bgs.protocol.connection.v1.EchoRequest: {1}) returned bgs.protocol.connection.v1.EchoResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
DisconnectNotification request = DisconnectNotification.Parser.ParseFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleForceDisconnect(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.ForceDisconnect(bgs.protocol.connection.v1.DisconnectNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
NoData request = NoData.Parser.ParseFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleKeepAlive(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.KeepAlive(bgs.protocol.NoData: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
EncryptRequest request = EncryptRequest.Parser.ParseFrom(stream);
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleEncrypt(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.Encrypt(bgs.protocol.connection.v1.EncryptRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
DisconnectRequest request = DisconnectRequest.Parser.ParseFrom(stream);
|
||||
|
||||
BattlenetRpcErrorCode status = HandleRequestDisconnect(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ConnectionService.RequestDisconnect(bgs.protocol.connection.v1.DisconnectRequest: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleConnect(ConnectRequest request, ConnectResponse response)
|
||||
{
|
||||
if (request.ClientId != null)
|
||||
response.ClientId.MergeFrom(request.ClientId);
|
||||
|
||||
response.ServerId = new ProcessId();
|
||||
response.ServerId.Label = (uint)Process.GetCurrentProcess().Id;
|
||||
response.ServerId.Epoch = (uint)Time.UnixTime;
|
||||
response.ServerTime = (ulong)Time.UnixTimeMilliseconds;
|
||||
|
||||
response.UseBindlessRpc = request.UseBindlessRpc;
|
||||
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleBind(BindRequest request, BindResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.Bind: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleEcho(EchoRequest request, EchoResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.Echo: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleForceDisconnect(DisconnectNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.ForceDisconnect: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleKeepAlive(NoData request)
|
||||
{
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleEncrypt(EncryptRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ConnectionService.Encrypt: {1}", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleRequestDisconnect(DisconnectRequest request)
|
||||
{
|
||||
var disconnectNotification = new DisconnectNotification();
|
||||
disconnectNotification.ErrorCode = request.ErrorCode;
|
||||
SendRequest(4, disconnectNotification);
|
||||
|
||||
_session.CloseSocket();
|
||||
return BattlenetRpcErrorCode.Ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Friends.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class FriendsService : ServiceBase
|
||||
{
|
||||
public FriendsService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
SubscribeRequest request = new SubscribeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
SubscribeResponse response = new SubscribeResponse();
|
||||
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.Subscribe(bgs.protocol.friends.v1.SubscribeRequest: {1}) returned bgs.protocol.friends.v1.SubscribeResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
SendInvitationRequest request = new SendInvitationRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSendInvitation(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.SendInvitation(bgs.protocol.SendInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
GenericInvitationRequest request = new GenericInvitationRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleAcceptInvitation(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.AcceptInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
GenericInvitationRequest request = new GenericInvitationRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleRevokeInvitation(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.RevokeInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
GenericInvitationRequest request = new GenericInvitationRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleDeclineInvitation(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.DeclineInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
GenericInvitationRequest request = new GenericInvitationRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleIgnoreInvitation(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.IgnoreInvitation(bgs.protocol.GenericInvitationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
AssignRoleRequest request = new AssignRoleRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleAssignRole(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.AssignRole(bgs.protocol.friends.v1.AssignRoleRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
GenericFriendRequest request = new GenericFriendRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GenericFriendResponse response = new GenericFriendResponse();
|
||||
BattlenetRpcErrorCode status = HandleRemoveFriend(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.RemoveFriend(bgs.protocol.friends.v1.GenericFriendRequest: {1}) returned bgs.protocol.friends.v1.GenericFriendResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
ViewFriendsRequest request = new ViewFriendsRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
ViewFriendsResponse response = new ViewFriendsResponse();
|
||||
BattlenetRpcErrorCode status = HandleViewFriends(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.ViewFriends(bgs.protocol.friends.v1.ViewFriendsRequest: {1}) returned bgs.protocol.friends.v1.ViewFriendsResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
UpdateFriendStateRequest request = new UpdateFriendStateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUpdateFriendState(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.UpdateFriendState(bgs.protocol.friends.v1.UpdateFriendStateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
{
|
||||
UnsubscribeRequest request = new UnsubscribeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.Unsubscribe(bgs.protocol.friends.v1.UnsubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
{
|
||||
GenericFriendRequest request = new GenericFriendRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleRevokeAllInvitations(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.RevokeAllInvitations(bgs.protocol.friends.v1.GenericFriendRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
/*case 13:
|
||||
{
|
||||
GetFriendListRequest request = new GetFriendListRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GetFriendListResponse response = new GetFriendListResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetFriendList(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.GetFriendList(bgs.protocol.friends.v1.GetFriendListRequest: {1}) returned bgs.protocol.friends.v1.GetFriendListResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 14:
|
||||
{
|
||||
CreateFriendshipRequest request = new CreateFriendshipRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleCreateFriendship(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsService.CreateFriendship(bgs.protocol.friends.v1.CreateFriendshipRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}*/
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSubscribe(SubscribeRequest request, SubscribeResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.Subscribe: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSendInvitation(SendInvitationRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.SendInvitation: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleAcceptInvitation(GenericInvitationRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.AcceptInvitation: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleRevokeInvitation(GenericInvitationRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.RevokeInvitation: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleDeclineInvitation(GenericInvitationRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.DeclineInvitation: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleIgnoreInvitation(GenericInvitationRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.IgnoreInvitation: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleAssignRole(AssignRoleRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.AssignRole: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleRemoveFriend(GenericFriendRequest request, GenericFriendResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.RemoveFriend: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleViewFriends(ViewFriendsRequest request, ViewFriendsResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.ViewFriends: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUpdateFriendState(UpdateFriendStateRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.UpdateFriendState: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUnsubscribe(UnsubscribeRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.Unsubscribe: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleRevokeAllInvitations(GenericFriendRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.RevokeAllInvitations: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
/*BattlenetRpcErrorCode HandleGetFriendList(GetFriendListRequest request, GetFriendListResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.GetFriendList: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleCreateFriendship(CreateFriendshipRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsService.CreateFriendship: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class FriendsListener : ServiceBase
|
||||
{
|
||||
public FriendsListener(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
FriendNotification request = new FriendNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnFriendAdded(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnFriendAdded(bgs.protocol.friends.v1.FriendNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
FriendNotification request = new FriendNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnFriendRemoved(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnFriendRemoved(bgs.protocol.friends.v1.FriendNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
InvitationNotification request = new InvitationNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnReceivedInvitationAdded(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnReceivedInvitationAdded(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
InvitationNotification request = new InvitationNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnReceivedInvitationRemoved(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnReceivedInvitationRemoved(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
InvitationNotification request = new InvitationNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnSentInvitationAdded(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnSentInvitationAdded(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
InvitationNotification request = new InvitationNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnSentInvitationRemoved(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnSentInvitationRemoved(bgs.protocol.friends.v1.InvitationNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
UpdateFriendStateNotification request = new UpdateFriendStateNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnUpdateFriendState(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method FriendsListener.OnUpdateFriendState(bgs.protocol.friends.v1.UpdateFriendStateNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnFriendAdded(FriendNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnFriendAdded: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnFriendRemoved(FriendNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnFriendRemoved: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnReceivedInvitationAdded(InvitationNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnReceivedInvitationAdded: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnReceivedInvitationRemoved(InvitationNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnReceivedInvitationRemoved: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnSentInvitationAdded(InvitationNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnSentInvitationAdded: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnSentInvitationRemoved(InvitationNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnSentInvitationRemoved: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnUpdateFriendState(UpdateFriendStateNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method FriendsListener.OnUpdateFriendState: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.GameUtilities.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class GameUtilitiesService : ServiceBase
|
||||
{
|
||||
public GameUtilitiesService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
ClientRequest request = new ClientRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
ClientResponse response = new ClientResponse();
|
||||
BattlenetRpcErrorCode status = HandleProcessClientRequest(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.ProcessClientRequest(bgs.protocol.game_utilities.v1.ClientRequest: {1}) returned bgs.protocol.game_utilities.v1.ClientResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
PresenceChannelCreatedRequest request = new PresenceChannelCreatedRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandlePresenceChannelCreated(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.PresenceChannelCreated(bgs.protocol.game_utilities.v1.PresenceChannelCreatedRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
GetPlayerVariablesRequest request = new GetPlayerVariablesRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GetPlayerVariablesResponse response = new GetPlayerVariablesResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetPlayerVariables(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.GetPlayerVariables(bgs.protocol.game_utilities.v1.GetPlayerVariablesRequest: {1}) returned bgs.protocol.game_utilities.v1.GetPlayerVariablesResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
ServerRequest request = new ServerRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
ServerResponse response = new ServerResponse();
|
||||
BattlenetRpcErrorCode status = HandleProcessServerRequest(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.ProcessServerRequest(bgs.protocol.game_utilities.v1.ServerRequest: {1}) returned bgs.protocol.game_utilities.v1.ServerResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
GameAccountOnlineNotification request = new GameAccountOnlineNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnGameAccountOnline(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.OnGameAccountOnline(bgs.protocol.game_utilities.v1.GameAccountOnlineNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
GameAccountOfflineNotification request = new GameAccountOfflineNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnGameAccountOffline(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.OnGameAccountOffline(bgs.protocol.game_utilities.v1.GameAccountOfflineNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
{
|
||||
GetAchievementsFileRequest request = new GetAchievementsFileRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GetAchievementsFileResponse response = new GetAchievementsFileResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetAchievementsFile(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.GetAchievementsFile(bgs.protocol.game_utilities.v1.GetAchievementsFileRequest: {1}) returned bgs.protocol.game_utilities.v1.GetAchievementsFileResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
GetAllValuesForAttributeRequest request = new GetAllValuesForAttributeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
GetAllValuesForAttributeResponse response = new GetAllValuesForAttributeResponse();
|
||||
BattlenetRpcErrorCode status = HandleGetAllValuesForAttribute(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method GameUtilitiesService.GetAllValuesForAttribute(bgs.protocol.game_utilities.v1.GetAllValuesForAttributeRequest: {1}) returned bgs.protocol.game_utilities.v1.GetAllValuesForAttributeResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleProcessClientRequest(ClientRequest request, ClientResponse response)
|
||||
{
|
||||
return _session.HandleProcessClientRequest(request, response);
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandlePresenceChannelCreated(PresenceChannelCreatedRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.PresenceChannelCreated: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetPlayerVariables(GetPlayerVariablesRequest request, GetPlayerVariablesResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.GetPlayerVariables: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleProcessServerRequest(ServerRequest request, ServerResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.ProcessServerRequest: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnGameAccountOnline(GameAccountOnlineNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.OnGameAccountOnline: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnGameAccountOffline(GameAccountOfflineNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.OnGameAccountOffline: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetAchievementsFile(GetAchievementsFileRequest request, GetAchievementsFileResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method GameUtilitiesService.GetAchievementsFile: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleGetAllValuesForAttribute(GetAllValuesForAttributeRequest request, GetAllValuesForAttributeResponse response)
|
||||
{
|
||||
return _session.HandleGetAllValuesForAttribute(request, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Presence.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class PresenceService : ServiceBase
|
||||
{
|
||||
public PresenceService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
SubscribeRequest request = new SubscribeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Subscribe(bgs.protocol.presence.v1.SubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
UnsubscribeRequest request = new UnsubscribeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Unsubscribe(bgs.protocol.presence.v1.UnsubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
UpdateRequest request = new UpdateRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUpdate(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Update(bgs.protocol.presence.v1.UpdateRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
QueryRequest request = new QueryRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
QueryResponse response = new QueryResponse();
|
||||
BattlenetRpcErrorCode status = HandleQuery(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Query(bgs.protocol.presence.v1.QueryRequest: {1}) returned bgs.protocol.presence.v1.QueryResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
OwnershipRequest request = new OwnershipRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleOwnership(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.Ownership(bgs.protocol.presence.v1.OwnershipRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
SubscribeNotificationRequest request = new SubscribeNotificationRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSubscribeNotification(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.SubscribeNotification(bgs.protocol.presence.v1.SubscribeNotificationRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
/*case 8:
|
||||
{
|
||||
MigrateOlympusCustomMessageRequest request = new MigrateOlympusCustomMessageRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
MigrateOlympusCustomMessageResponse response = new MigrateOlympusCustomMessageResponse();
|
||||
BattlenetRpcErrorCode status = HandleMigrateOlympusCustomMessage(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method PresenceService.MigrateOlympusCustomMessage(bgs.protocol.presence.v1.MigrateOlympusCustomMessageRequest: {1}) returned bgs.protocol.presence.v1.MigrateOlympusCustomMessageResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}*/
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSubscribe(SubscribeRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Subscribe: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUnsubscribe(UnsubscribeRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Unsubscribe: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUpdate(UpdateRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Update: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleQuery(QueryRequest request, QueryResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Query: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOwnership(OwnershipRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.Ownership: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSubscribeNotification(SubscribeNotificationRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.SubscribeNotification: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
/*BattlenetRpcErrorCode HandleMigrateOlympusCustomMessage(MigrateOlympusCustomMessageRequest request, MigrateOlympusCustomMessageResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method PresenceService.MigrateOlympusCustomMessage: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.Report.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class ReportService : ServiceBase
|
||||
{
|
||||
public ReportService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
SendReportRequest request = new SendReportRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSendReport(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ReportService.SendReport(bgs.protocol.report.v1.SendReportRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
/*case 2:
|
||||
{
|
||||
SubmitReportRequest request = new SubmitReportRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleSubmitReport(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ReportService.SubmitReport(bgs.protocol.report.v1.SubmitReportRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}*/
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSendReport(SendReportRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ReportService.SendReport: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
/* BattlenetRpcErrorCode HandleSubmitReport(SubmitReportRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ReportService.SubmitReport: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class ResourcesService : ServiceBase
|
||||
{
|
||||
public ResourcesService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
/*case 1:
|
||||
{
|
||||
ContentHandleRequest request = new ContentHandleRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
ContentHandle response = new ContentHandle();
|
||||
BattlenetRpcErrorCode status = HandleGetContentHandle(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method ResourcesService.GetContentHandle(bgs.protocol.resources.v1.ContentHandleRequest: {1}) returned bgs.protocol.ContentHandle: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}*/
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*BattlenetRpcErrorCode HandleGetContentHandle(ContentHandleRequest request, ContentHandle response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method ResourcesService.GetContentHandle({1})", GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2016 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using BNetServer.Networking;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BNetServer.Services
|
||||
{
|
||||
public class ServiceDispatcher : Singleton<ServiceDispatcher>
|
||||
{
|
||||
ServiceDispatcher()
|
||||
{
|
||||
AddService<AccountService>(OriginalHash.AccountService);
|
||||
AddService<AccountListener>(OriginalHash.AccountListener);
|
||||
AddService<AuthenticationService>(OriginalHash.AuthenticationService);
|
||||
AddService<ChallengeService>(OriginalHash.ChallengeService);
|
||||
AddService<ChannelService>(OriginalHash.ChannelService);
|
||||
AddService<ConnectionService>(OriginalHash.ConnectionService);
|
||||
AddService<FriendsService>(OriginalHash.FriendsService);
|
||||
AddService<GameUtilitiesService>(OriginalHash.GameUtilitiesService);
|
||||
AddService<PresenceService>(OriginalHash.PresenceService);
|
||||
AddService<ReportService>(OriginalHash.ReportService);
|
||||
AddService<ResourcesService>(OriginalHash.ResourcesService);
|
||||
AddService<UserManagerService>(OriginalHash.UserManagerService);
|
||||
}
|
||||
|
||||
public void Dispatch(Session session, uint serviceHash, uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
var action = _dispatchers.LookupByKey(serviceHash);
|
||||
if (action != null)
|
||||
action(session, serviceHash, token, methodId, stream);
|
||||
else
|
||||
Log.outDebug(LogFilter.SessionRpc, "{0} tried to call invalid service {1}", session.GetClientInfo(), serviceHash);
|
||||
}
|
||||
|
||||
void AddService<Service>(OriginalHash OriginalHash) where Service : ServiceBase
|
||||
{
|
||||
_dispatchers[(uint)OriginalHash] = Dispatch<Service>;
|
||||
}
|
||||
|
||||
void Dispatch<Service>(Session session, uint serviceHash, uint token, uint methodId, CodedInputStream stream) where Service : ServiceBase
|
||||
{
|
||||
var obj = (Service)Activator.CreateInstance(typeof(Service), session, serviceHash);
|
||||
obj.CallServerMethod(token, methodId, stream);
|
||||
}
|
||||
|
||||
Dictionary<uint, DispatcherHandler> _dispatchers = new Dictionary<uint, DispatcherHandler>();
|
||||
|
||||
delegate void DispatcherHandler(Session session, uint serviceHash, uint token, uint methodId, CodedInputStream stream);
|
||||
}
|
||||
|
||||
abstract class ServiceBase
|
||||
{
|
||||
public ServiceBase(Session session, uint serviceHash)
|
||||
{
|
||||
_session = session;
|
||||
_serviceHash = serviceHash;
|
||||
}
|
||||
|
||||
public abstract void CallServerMethod(uint token, uint methodId, CodedInputStream stream);
|
||||
|
||||
public void SendRequest(uint methodId, IMessage request, Action<CodedInputStream> callback) { _session.SendRequest(_serviceHash, methodId, request, callback); }
|
||||
public void SendRequest(uint methodId, IMessage request) { _session.SendRequest(_serviceHash, methodId, request); }
|
||||
public void SendResponse(uint token, BattlenetRpcErrorCode status) { _session.SendResponse(token, status); }
|
||||
public void SendResponse(uint token, IMessage response) { _session.SendResponse(token, response); }
|
||||
|
||||
public string GetCallerInfo()
|
||||
{
|
||||
return _session.GetClientInfo();
|
||||
}
|
||||
|
||||
protected Session _session;
|
||||
protected uint _serviceHash;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,319 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2017 CypherCore <http://github.com/CypherCore>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Bgs.Protocol;
|
||||
using Bgs.Protocol.UserManager.V1;
|
||||
using BNetServer.Services;
|
||||
using Framework.Constants;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace BNetServer.Networking
|
||||
{
|
||||
class UserManagerService : ServiceBase
|
||||
{
|
||||
public UserManagerService(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
SubscribeRequest request = new SubscribeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
SubscribeResponse response = new SubscribeResponse();
|
||||
BattlenetRpcErrorCode status = HandleSubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.Subscribe(bgs.protocol.user_manager.v1.SubscribeRequest: {1}) returned bgs.protocol.user_manager.v1.SubscribeResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
AddRecentPlayersRequest request = new AddRecentPlayersRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
AddRecentPlayersResponse response = new AddRecentPlayersResponse();
|
||||
BattlenetRpcErrorCode status = HandleAddRecentPlayers(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.AddRecentPlayers(bgs.protocol.user_manager.v1.AddRecentPlayersRequest: {1}) returned bgs.protocol.user_manager.v1.AddRecentPlayersResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
{
|
||||
ClearRecentPlayersRequest request = new ClearRecentPlayersRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
ClearRecentPlayersResponse response = new ClearRecentPlayersResponse();
|
||||
BattlenetRpcErrorCode status = HandleClearRecentPlayers(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.ClearRecentPlayers(bgs.protocol.user_manager.v1.ClearRecentPlayersRequest: {1}) returned bgs.protocol.user_manager.v1.ClearRecentPlayersResponse: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 20:
|
||||
{
|
||||
BlockPlayerRequest request = new BlockPlayerRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleBlockPlayer(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.BlockPlayer(bgs.protocol.user_manager.v1.BlockPlayerRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
{
|
||||
UnblockPlayerRequest request = new UnblockPlayerRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUnblockPlayer(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.UnblockPlayer(bgs.protocol.user_manager.v1.UnblockPlayerRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 40:
|
||||
{
|
||||
BlockPlayerRequest request = new BlockPlayerRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleBlockPlayerForSession(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.BlockPlayerForSession(bgs.protocol.user_manager.v1.BlockPlayerRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 50:
|
||||
{
|
||||
EntityId request = new EntityId();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleLoadBlockList(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.LoadBlockList(bgs.protocol.EntityId: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 51:
|
||||
{
|
||||
UnsubscribeRequest request = new UnsubscribeRequest();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
NoData response = new NoData();
|
||||
BattlenetRpcErrorCode status = HandleUnsubscribe(request, response);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerService.Unsubscribe(bgs.protocol.user_manager.v1.UnsubscribeRequest: {1}) returned bgs.protocol.NoData: {2} status: {3}.",
|
||||
GetCallerInfo(), request.ToString(), response.ToString(), status);
|
||||
if (status == 0)
|
||||
SendResponse(token, response);
|
||||
else
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleSubscribe(SubscribeRequest request, SubscribeResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.Subscribe: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleAddRecentPlayers(AddRecentPlayersRequest request, AddRecentPlayersResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.AddRecentPlayers: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleClearRecentPlayers(ClearRecentPlayersRequest request, ClearRecentPlayersResponse response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.ClearRecentPlayers: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleBlockPlayer(BlockPlayerRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.BlockPlayer: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUnblockPlayer(UnblockPlayerRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.UnblockPlayer: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleBlockPlayerForSession(BlockPlayerRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.BlockPlayerForSession: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleLoadBlockList(EntityId request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.LoadBlockList: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleUnsubscribe(UnsubscribeRequest request, NoData response)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerService.Unsubscribe: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
|
||||
class UserManagerListener : ServiceBase
|
||||
{
|
||||
public UserManagerListener(Session session, uint serviceHash) : base(session, serviceHash) { }
|
||||
|
||||
public override void CallServerMethod(uint token, uint methodId, CodedInputStream stream)
|
||||
{
|
||||
switch (methodId)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
BlockedPlayerAddedNotification request = new BlockedPlayerAddedNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnBlockedPlayerAdded(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnBlockedPlayerAdded(bgs.protocol.user_manager.v1.BlockedPlayerAddedNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
BlockedPlayerRemovedNotification request = new BlockedPlayerRemovedNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnBlockedPlayerRemoved(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnBlockedPlayerRemoved(bgs.protocol.user_manager.v1.BlockedPlayerRemovedNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 11:
|
||||
{
|
||||
RecentPlayersAddedNotification request = new RecentPlayersAddedNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnRecentPlayersAdded(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnRecentPlayersAdded(bgs.protocol.user_manager.v1.RecentPlayersAddedNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
{
|
||||
RecentPlayersRemovedNotification request = new RecentPlayersRemovedNotification();
|
||||
request.MergeFrom(stream);
|
||||
|
||||
|
||||
BattlenetRpcErrorCode status = HandleOnRecentPlayersRemoved(request);
|
||||
Log.outDebug(LogFilter.ServiceProtobuf, "{0} Client called server method UserManagerListener.OnRecentPlayersRemoved(bgs.protocol.user_manager.v1.RecentPlayersRemovedNotification: {1}) status: {2}.",
|
||||
GetCallerInfo(), request.ToString(), status);
|
||||
if (status != 0)
|
||||
SendResponse(token, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.outError(LogFilter.ServiceProtobuf, "Bad method id {0}.", methodId);
|
||||
SendResponse(token, BattlenetRpcErrorCode.RpcInvalidMethod);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnBlockedPlayerAdded(BlockedPlayerAddedNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnBlockedPlayerAdded: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnBlockedPlayerRemoved(BlockedPlayerRemovedNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnBlockedPlayerRemoved: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnRecentPlayersAdded(RecentPlayersAddedNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnRecentPlayersAdded: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
|
||||
BattlenetRpcErrorCode HandleOnRecentPlayersRemoved(RecentPlayersRemovedNotification request)
|
||||
{
|
||||
Log.outError(LogFilter.ServiceProtobuf, "{0} Client tried to call not implemented method UserManagerListener.OnRecentPlayersRemoved: {1}",
|
||||
GetCallerInfo(), request.ToString());
|
||||
return BattlenetRpcErrorCode.RpcNotImplemented;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user