translation and static refactoring of GameRequestService.cs
This commit is contained in:
parent
1d1d877c41
commit
eb89fd4e5e
@ -36,79 +36,79 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
|||||||
}
|
}
|
||||||
public override void QueueMatchmaking(IRpcController controller, QueueMatchmakingRequest request, Action<QueueMatchmakingResponse> done)
|
public override void QueueMatchmaking(IRpcController controller, QueueMatchmakingRequest request, Action<QueueMatchmakingResponse> done)
|
||||||
{
|
{
|
||||||
#region Инициализация игры
|
#region Game initialization
|
||||||
|
|
||||||
var id = RequestId.CreateBuilder().SetId(Counter); Counter++;
|
var id = RequestId.CreateBuilder().SetId(Counter); Counter++;
|
||||||
|
|
||||||
done(QueueMatchmakingResponse.CreateBuilder().SetRequestId(id).Build());
|
done(QueueMatchmakingResponse.CreateBuilder().SetRequestId(id).Build());
|
||||||
#endregion
|
#endregion
|
||||||
string request_type = "";
|
string requestType = "";
|
||||||
string ServerPool = "";
|
string serverPool = "";
|
||||||
bgs.protocol.v2.Attribute AttributeOfServer = null;
|
bgs.protocol.v2.Attribute attributeOfServer = null;
|
||||||
GameCreateParams gameCreateParams = null;
|
GameCreateParams gameCreateParams = null;
|
||||||
|
|
||||||
int Difficulty = 0;
|
int difficulty = 0;
|
||||||
int CurrentAct = 0;
|
int currentAct = 0;
|
||||||
int CurrentQuest = 0;
|
int currentQuest = 0;
|
||||||
int CurrentStep = 0;
|
int currentStep = 0;
|
||||||
foreach (var attr in request.Options.CreationProperties.AttributeList)
|
foreach (var attr in request.Options.CreationProperties.AttributeList)
|
||||||
{
|
{
|
||||||
switch (attr.Name)
|
switch (attr.Name)
|
||||||
{
|
{
|
||||||
case "GameCreateParams":
|
case "GameCreateParams":
|
||||||
gameCreateParams = GameCreateParams.ParseFrom(attr.Value.BlobValue);
|
gameCreateParams = GameCreateParams.ParseFrom(attr.Value.BlobValue);
|
||||||
AttributeOfServer = attr;
|
attributeOfServer = attr;
|
||||||
break;
|
break;
|
||||||
case "ServerPool":
|
case "ServerPool":
|
||||||
ServerPool = attr.Value.StringValue;
|
serverPool = attr.Value.StringValue;
|
||||||
break;
|
break;
|
||||||
case "request_type":
|
case "request_type":
|
||||||
request_type = attr.Value.StringValue;
|
requestType = attr.Value.StringValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Difficulty = gameCreateParams.CampaignOrAdventureMode.HandicapLevel;
|
difficulty = gameCreateParams.CampaignOrAdventureMode.HandicapLevel;
|
||||||
CurrentAct = gameCreateParams.CampaignOrAdventureMode.Act;
|
currentAct = gameCreateParams.CampaignOrAdventureMode.Act;
|
||||||
CurrentQuest = gameCreateParams.CampaignOrAdventureMode.SnoQuest;
|
currentQuest = gameCreateParams.CampaignOrAdventureMode.SnoQuest;
|
||||||
CurrentStep = gameCreateParams.CampaignOrAdventureMode.QuestStepId;
|
currentStep = gameCreateParams.CampaignOrAdventureMode.QuestStepId;
|
||||||
|
|
||||||
#region Ставим в очередь
|
#region Put in queue
|
||||||
QueueWaitTimes.Builder timers = QueueWaitTimes.CreateBuilder();
|
QueueWaitTimes.Builder timers = QueueWaitTimes.CreateBuilder();
|
||||||
timers.SetMinWait(0).SetMaxWait(120).SetAvgWait(60).SetStdDevWait(0);
|
timers.SetMinWait(0).SetMaxWait(120).SetAvgWait(60).SetStdDevWait(0);
|
||||||
|
|
||||||
var member = bgs.protocol.account.v1.GameAccountHandle.CreateBuilder();
|
var member = bgs.protocol.account.v1.GameAccountHandle.CreateBuilder();
|
||||||
member.SetId((uint)(controller as HandlerController).Client.Account.GameAccount.BnetEntityId.Low).SetProgram(0x00004433).SetRegion(1);
|
member.SetId((uint)((HandlerController) controller).Client.Account.GameAccount.BnetEntityId.Low).SetProgram(0x00004433).SetRegion(1);
|
||||||
|
|
||||||
QueueEntryNotification.Builder qen = QueueEntryNotification.CreateBuilder();
|
QueueEntryNotification.Builder qen = QueueEntryNotification.CreateBuilder();
|
||||||
qen.SetRequestId(id).SetWaitTimes(timers).AddMember(member).SetRequestInitiator(member);
|
qen.SetRequestId(id).SetWaitTimes(timers).AddMember(member).SetRequestInitiator(member);
|
||||||
(controller as HandlerController).Client.MakeRPC((lid) => GameRequestListener.CreateStub((controller as HandlerController).Client).OnQueueEntry(new HandlerController() { ListenerId = lid }, qen.Build(), callback => { }));
|
((HandlerController) controller).Client.MakeRPC((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnQueueEntry(new HandlerController() { ListenerId = lid }, qen.Build(), callback => { }));
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Обновление очереди
|
#region Update Queue
|
||||||
QueueUpdateNotification.Builder qun = QueueUpdateNotification.CreateBuilder();
|
QueueUpdateNotification.Builder qun = QueueUpdateNotification.CreateBuilder();
|
||||||
qun.SetRequestId(id)
|
qun.SetRequestId(id)
|
||||||
.SetWaitTimes(timers)
|
.SetWaitTimes(timers)
|
||||||
.SetIsMatchmaking(true);
|
.SetIsMatchmaking(true);
|
||||||
(controller as HandlerController).Client.MakeRPC((lid) => GameRequestListener.CreateStub((controller as HandlerController).Client).OnQueueUpdate(new HandlerController() { ListenerId = lid }, qun.Build(), callback => { }));
|
((HandlerController) controller).Client.MakeRPC((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnQueueUpdate(new HandlerController() { ListenerId = lid }, qun.Build(), callback => { }));
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
string GAME_SERVER_IP = Program.GAMESERVERIP;
|
string gameServerIp = Program.GAMESERVERIP;
|
||||||
if (GameServer.NATConfig.Instance.Enabled)
|
if (GameServer.NATConfig.Instance.Enabled)
|
||||||
GAME_SERVER_IP = Program.PUBLICGAMESERVERIP;
|
gameServerIp = Program.PUBLICGAMESERVERIP;
|
||||||
uint GAME_SERVER_PORT = 2001;
|
uint gameServerPort = 2001;
|
||||||
|
|
||||||
MatchmakingResultNotification.Builder notification = MatchmakingResultNotification.CreateBuilder();
|
MatchmakingResultNotification.Builder notification = MatchmakingResultNotification.CreateBuilder();
|
||||||
ConnectInfo.Builder connectInfo = ConnectInfo.CreateBuilder();
|
ConnectInfo.Builder connectInfo = ConnectInfo.CreateBuilder();
|
||||||
connectInfo.SetAddress(Address.CreateBuilder().SetAddress_(GAME_SERVER_IP).SetPort(GAME_SERVER_PORT));
|
connectInfo.SetAddress(Address.CreateBuilder().SetAddress_(gameServerIp).SetPort(gameServerPort));
|
||||||
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("GameAccount").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetBlobValue(member.Build().ToByteString())));
|
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("GameAccount").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetBlobValue(member.Build().ToByteString())));
|
||||||
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("Token").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetUintValue(0xEEF4364684EE186E))); // FIXME
|
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("Token").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetUintValue(0xEEF4364684EE186E))); // FIXME
|
||||||
connectInfo.AddAttribute(AttributeOfServer); // Настройки игры
|
connectInfo.AddAttribute(attributeOfServer); // Настройки игры
|
||||||
|
|
||||||
GameHandle.Builder gh = GameHandle.CreateBuilder();
|
GameHandle.Builder gh = GameHandle.CreateBuilder();
|
||||||
gh.SetMatchmaker(MatchmakerHandle.CreateBuilder()
|
gh.SetMatchmaker(MatchmakerHandle.CreateBuilder()
|
||||||
.SetId((uint)(controller as HandlerController).Client.Account.GameAccount.BnetEntityId.Low)
|
.SetId((uint)((HandlerController) controller).Client.Account.GameAccount.BnetEntityId.Low)
|
||||||
.SetAddr(HostProxyPair.CreateBuilder()
|
.SetAddr(HostProxyPair.CreateBuilder()
|
||||||
.SetHost(ProcessId.CreateBuilder().SetLabel(1250).SetEpoch(1499729350))
|
.SetHost(ProcessId.CreateBuilder().SetLabel(1250).SetEpoch(1499729350))
|
||||||
.SetProxy(ProcessId.CreateBuilder().SetLabel(0xaa82dfd9).SetEpoch(1497363883))));
|
.SetProxy(ProcessId.CreateBuilder().SetLabel(0xaa82dfd9).SetEpoch(1497363883))));
|
||||||
@ -116,10 +116,10 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
|||||||
.SetHost(ProcessId.CreateBuilder().SetLabel(1277).SetEpoch(1499729371))
|
.SetHost(ProcessId.CreateBuilder().SetLabel(1277).SetEpoch(1499729371))
|
||||||
.SetProxy(ProcessId.CreateBuilder().SetLabel(0xf511871c).SetEpoch(1497363865)));
|
.SetProxy(ProcessId.CreateBuilder().SetLabel(0xf511871c).SetEpoch(1497363865)));
|
||||||
|
|
||||||
var gameFound = GameFactoryManager.FindGame((controller as HandlerController).Client, request, ++GameFactoryManager.RequestIdCounter);
|
var gameFound = GameFactoryManager.FindGame(((HandlerController) controller).Client, request, ++GameFactoryManager.RequestIdCounter);
|
||||||
var clients = (from player in request.Options.PlayerList select GameAccountManager.GetAccountByPersistentID(player.GameAccount.Id) into gameAccount where gameFound != null select gameAccount.LoggedInClient).ToList();
|
var clients = (from player in request.Options.PlayerList select GameAccountManager.GetAccountByPersistentID(player.GameAccount.Id) into gameAccount where gameFound != null select gameAccount.LoggedInClient).ToList();
|
||||||
|
|
||||||
if (((controller as HandlerController).Client).CurrentChannel != null)
|
if ((((HandlerController)controller).Client).CurrentChannel != null)
|
||||||
{
|
{
|
||||||
var channelStatePermission = bgs.protocol.channel.v1.ChannelState.CreateBuilder()
|
var channelStatePermission = bgs.protocol.channel.v1.ChannelState.CreateBuilder()
|
||||||
.AddAttribute(bgs.protocol.Attribute.CreateBuilder()
|
.AddAttribute(bgs.protocol.Attribute.CreateBuilder()
|
||||||
@ -128,27 +128,27 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
|||||||
.Build()).Build();
|
.Build()).Build();
|
||||||
|
|
||||||
var notificationPermission = bgs.protocol.channel.v1.UpdateChannelStateNotification.CreateBuilder()
|
var notificationPermission = bgs.protocol.channel.v1.UpdateChannelStateNotification.CreateBuilder()
|
||||||
.SetAgentId(((controller as HandlerController).Client).Account.GameAccount.BnetEntityId)
|
.SetAgentId((((HandlerController) controller).Client).Account.GameAccount.BnetEntityId)
|
||||||
.SetStateChange(channelStatePermission)
|
.SetStateChange(channelStatePermission)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var JoinPerm = bgs.protocol.channel.v1.JoinNotification.CreateBuilder().SetChannelState(channelStatePermission).Build();
|
var joinNotification = bgs.protocol.channel.v1.JoinNotification.CreateBuilder().SetChannelState(channelStatePermission).Build();
|
||||||
|
|
||||||
((controller as HandlerController).Client).MakeTargetedRPC(((controller as HandlerController).Client).CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(((controller as HandlerController).Client)).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPermission, callback => { }));
|
(((HandlerController) controller).Client).MakeTargetedRPC((((HandlerController) controller).Client).CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub((((HandlerController) controller).Client)).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPermission, callback => { }));
|
||||||
}
|
}
|
||||||
gameFound.StartGame(clients, gameFound.DynamicId);
|
gameFound.StartGame(clients, gameFound.DynamicId);
|
||||||
|
|
||||||
var notificationFound = bgs.protocol.notification.v1.Notification.CreateBuilder()
|
var notificationFound = bgs.protocol.notification.v1.Notification.CreateBuilder()
|
||||||
.SetSenderId(bgs.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(0).Build())
|
.SetSenderId(bgs.protocol.EntityId.CreateBuilder().SetHigh((ulong)EntityIdHelper.HighIdType.GameAccountId).SetLow(0).Build())
|
||||||
.SetTargetId(((controller as HandlerController).Client).Account.GameAccount.BnetEntityId)
|
.SetTargetId((((HandlerController) controller).Client).Account.GameAccount.BnetEntityId)
|
||||||
.SetType("GQ_ENTRY");
|
.SetType("GQ_ENTRY");
|
||||||
var attrF = bgs.protocol.Attribute.CreateBuilder()
|
var attrF = bgs.protocol.Attribute.CreateBuilder()
|
||||||
.SetName("game_request_id")
|
.SetName("game_request_id")
|
||||||
.SetValue(bgs.protocol.Variant.CreateBuilder().SetUintValue(gameFound.RequestId).Build());
|
.SetValue(bgs.protocol.Variant.CreateBuilder().SetUintValue(gameFound.RequestId).Build());
|
||||||
notificationFound.AddAttribute(attrF);
|
notificationFound.AddAttribute(attrF);
|
||||||
|
|
||||||
((controller as HandlerController).Client).MakeRPC((lid) =>
|
(((HandlerController) controller).Client).MakeRPC((lid) =>
|
||||||
bgs.protocol.notification.v1.NotificationListener.CreateStub(((controller as HandlerController).Client)).OnNotificationReceived(new HandlerController() { ListenerId = lid }, notificationFound.Build(), callback => { }));
|
bgs.protocol.notification.v1.NotificationListener.CreateStub((((HandlerController) controller).Client)).OnNotificationReceived(new HandlerController() { ListenerId = lid }, notificationFound.Build(), callback => { }));
|
||||||
|
|
||||||
|
|
||||||
gh.SetGameInstanceId((uint)gameFound.BnetEntityId.Low);
|
gh.SetGameInstanceId((uint)gameFound.BnetEntityId.Low);
|
||||||
@ -162,7 +162,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
|||||||
notification.SetGameHandle(gh);
|
notification.SetGameHandle(gh);
|
||||||
|
|
||||||
System.Threading.Tasks.Task.Delay(2000).ContinueWith(delegate {
|
System.Threading.Tasks.Task.Delay(2000).ContinueWith(delegate {
|
||||||
(controller as HandlerController).Client.MakeRPC((lid) => GameRequestListener.CreateStub((controller as HandlerController).Client).OnMatchmakingResult(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { }));
|
((HandlerController) controller).Client.MakeRPC((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnMatchmakingResult(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
user.block.title