public async Task <IActionResult> ReportAcceptPlayer([FromBody] ReportAcceptPlayer.Request req) { var requester = new evomatching.ProtocolModels.Matching.ReportAcceptPlayer(); requester.request.battleServerSessionId = SelfHost.sessionId; requester.request.joinPassword = req.joinPassword; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } var res = new ReportAcceptPlayer.Response { playerId = response.Payload.playerId, allowed = response.Payload.allowed, side = response.Payload.side, rating = response.Payload.rating, }; if (response.Payload.allowed) { var player = new Player(response.Payload.playerId); await player.FetchAsync(); res.privilegeLevel = player.Model.privilegeLevel; res.sessionId = player.Model.sessionId; } return(Ok(res)); }
public async Task <IActionResult> ResponseInvitation([FromBody] ResponseInvitation.Request req) { var requester = new evomatching.ProtocolModels.PremadeGroup.ResponseInvitation(); requester.request.playerIdSrc = req.playerId; requester.request.playerIdDst = SelfHost.playerInfo.playerId; requester.request.approved = req.approved; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } switch (response.Payload.resultCode) { case evomatching.ProtocolModels.PremadeGroup.ResponseInvitation.Response.ResultCode.Ok: return(Ok(new ResponseInvitation.Response())); case evomatching.ProtocolModels.PremadeGroup.ResponseInvitation.Response.ResultCode.Timeup: return(BuildErrorResponse(Error.LowCode.PremadeGroupResponseTimeup)); default: return(BuildErrorResponse(Error.LowCode.BadRequest)); } }
public async Task <IActionResult> EntryBattleServer([FromBody] EntryBattleServer.Request req) { var requester = new evomatching.ProtocolModels.Matching.EntryBattleServer(); requester.request.sessionId = SelfHost.sessionId; requester.request.ipAddr = req.ipAddr; requester.request.port = req.port.Value; requester.request.rule = req.rule; requester.request.mapId = req.mapId; requester.request.autoMatchmakeTarget = req.autoMatchmakeTarget.Value; requester.request.label = req.label; requester.request.description = req.description; requester.request.serverName = req.serverName; requester.request.region = req.region; requester.request.owner = req.owner; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var session = new Session(SelfHost.sessionId); session.Model.matchId = response.Payload.matchId; await session.SaveAsync(); } return(Ok(new EntryBattleServer.Response { })); }
public Startup(IConfiguration configuration) { Configuration = configuration; { var map = new Dictionary <string, List <String> >(); var kvsConnectionsSection = Configuration.GetSection("KvsConnections"); foreach (var item in kvsConnectionsSection.GetChildren()) { map[item.Key] = item.Get <List <string> >(); } evolib.Kvs.Kvs.Initialize(map); } EvoToolJwt.issuer = Configuration["Jwt:issuer"]; EvoToolJwt.audience = Configuration["Jwt:audience"]; EvoToolJwt.expiryMinutes = int.Parse(Configuration["Jwt:expiryMinutes"]); MatchingServerInfo.Initialize(Configuration); AuthenticationServerInfo.Initialize(Configuration); DeliveryDataInfo.Initialize(Configuration); DbContextFactory.Initialize(Configuration); System.Threading.Tasks.Task.Run(async() => { using (var commonDB2 = DbContextFactory.CreateCommon2()) { await TranslationTable.LoadAsync(commonDB2); } }); }
public async Task <IActionResult> EntryPlayer([FromBody] EntryPlayer.Request req) { if (req.pingResults != null) { var results = new List <LogModels.PingResults.Result>(); foreach (var pingResult in req.pingResults) { results.Add(new LogModels.PingResults.Result { regionCode = pingResult.regionCode, time = pingResult.time, }); } Logger.Logging( new LogObj().AddChild(new LogModels.PingResults { PlayerId = SelfHost.playerInfo.playerId, Results = results, }) ); } if (!VersionChecker.Get(VersionChecker.CheckTarget.EnabledMatchmake).Check()) { return(BuildErrorResponse(Error.LowCode.DisabledMatchmake)); } var requester = new evomatching.ProtocolModels.Matching.EntryPlayer(); requester.request.playerId = SelfHost.playerInfo.playerId; requester.request.matchType = req.matchType.Value; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } switch (response.Payload.resultCode) { case evomatching.ProtocolModels.Matching.EntryPlayer.Response.ResultCode.Ok: return(Ok(new EntryPlayer.Response())); case evomatching.ProtocolModels.Matching.EntryPlayer.Response.ResultCode.OldPackageVersion: return(BuildErrorResponse(Error.LowCode.NgPackageVersion)); case evomatching.ProtocolModels.Matching.EntryPlayer.Response.ResultCode.SendedPgInvitation: return(BuildErrorResponse(Error.LowCode.SentPgInvitation)); case evomatching.ProtocolModels.Matching.EntryPlayer.Response.ResultCode.RecievedPgInvitation: return(BuildErrorResponse(Error.LowCode.RecievedPgInvitation)); default: return(BuildErrorResponse(Error.LowCode.CouldNotMatchingEnty)); } }
public async Task <IActionResult> SemiAutoMatchmake([FromBody] SemiAutoMatchmake.Request req) { await MatchingServerInfo.MultiMatchingServersAsync(); var requester = new evomatching.ProtocolModels.Matching.SemiAutoMatchmake(); requester.request = req; var res = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(req.matchingArea.Value)); return(Ok(res.Payload)); }
public async Task <IActionResult> Say([FromBody] Say.Request req) { var requester = new evomatching.ProtocolModels.Chat.Chat(); requester.request.playerId = SelfHost.playerInfo.playerId; requester.request.type = req.type; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } Logger.Logging( new LogObj().AddChild(new LogModels.SayChat { PlayerId = SelfHost.playerInfo.playerId, Date = DateTime.UtcNow, ChatType = req.type.Value, GroupId = response.Payload.groupId, MatchId = response.Payload.matchId, Side = response.Payload.side, Text = req.text, }) ); var data = new Chat() { type = req.type.Value, playerId = SelfHost.playerInfo.playerId, playerName = SelfHost.playerInfo.playerName, text = req.text, }; if (response.Payload.sessionIds.Count == 0) { await new ConnectionQueue(SelfHost.sessionId).EnqueueAsync(data); } else { for (int i = 0; i < response.Payload.sessionIds.Count; i++) { var sessionId = response.Payload.sessionIds[i]; await new ConnectionQueue(sessionId).EnqueueAsync(data); } } var res = new Say.Response(); return(Ok(res)); }
public async Task <IActionResult> ForceMatchmake([FromBody] ForceMatchmake.Request req) { await MatchingServerInfo.MultiMatchingServersAsync(); var requester = new evomatching.ProtocolModels.Matching.ForceMatchmake(); requester.request = req; var res = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(req.matchingArea.Value)); return(Ok(new ForceMatchmake.Response { matchingArea = req.matchingArea.Value, })); }
public async Task <IActionResult> GetEntries([FromBody] GetEntries.Request req) { await MatchingServerInfo.MultiMatchingServersAsync(); var requester = new evomatching.ProtocolModels.Matching.GetEntries(); var res = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(req.matchingArea.Value)); return(Ok(new GetEntries.Response { entries = res.Payload.entries, battleServers = res.Payload.battleServers, matchingArea = req.matchingArea.Value, })); }
public Startup(IConfiguration configuration) { Configuration = configuration; { var map = new Dictionary <string, List <String> >(); var kvsConnectionsSection = Configuration.GetSection("KvsConnections"); foreach (var item in kvsConnectionsSection.GetChildren()) { map[item.Key] = item.Get <List <string> >(); } Kvs.Initialize(map); } EvoApiJwt.issuer = Configuration["Jwt:issuer"]; EvoApiJwt.audience = Configuration["Jwt:audience"]; EvoApiJwt.expiryMinutes = int.Parse(Configuration["Jwt:expiryMinutes"]); MatchingServerInfo.Initialize(Configuration); SequencingServerInfo.Initialize(Configuration); AuthenticationServerInfo.Initialize(Configuration); DeliveryDataInfo.Initialize(Configuration); evolib.SystemInfo.Initialize(Configuration); evolib.VivoxInfo.Initialize(Configuration); Task.Run(async() => { while (!await MatchingServerInfo.SetupMultiMatchingServersAsync()) { await Task.Delay(5000); } while (true) { await MasterDataLoader.LoadAsync(); await Task.Delay(5000); } }); evolib.Kvs.Models.Session.ExpiredSpan = TimeSpan.FromSeconds( ProtocolModels.HandShake.HandShake.NextResponseSeconds + 60); }
public async Task <IActionResult> Leave([FromBody] Leave.Request req) { var requester = new evomatching.ProtocolModels.PremadeGroup.Leave(); requester.request.playerId = SelfHost.playerInfo.playerId; requester.request.sessionId = SelfHost.sessionId; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } var res = new Leave.Response(); return(Ok(res)); }
public async Task <IActionResult> RequestLeaveBattle([FromBody] RequestLeaveBattle.Request req) { var requester = new evomatching.ProtocolModels.Matching.RequestLeaveBattleServer(); requester.request.playerId = SelfHost.playerInfo.playerId; requester.request.individual = req.individual.Value; var response = await requester.PostAsync(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response == null) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } var res = new RequestLeaveBattle.Response(); return(Ok(res)); }
public async Task <IActionResult> ReportBattlePhase([FromBody] ReportBattlePhase.Request req) { foreach (Battle.Phase phase in Enum.GetValues(typeof(Battle.Phase))) { var str = Enum.GetName(typeof(Battle.Phase), phase); if (str == req.phase) { var requester = new evomatching.ProtocolModels.Matching.ReportBattlePhase(); requester.request.battleServerSessionId = SelfHost.sessionId; requester.request.phase = phase; var response = await requester.PostAsync(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); var res = new ReportBattlePhase.Response(); return(Ok(res)); } } return(BuildErrorResponse(Error.LowCode.BadParameter)); }
public async Task <IActionResult> ReportDisconnectPlayer([FromBody] ReportDisconnectPlayer.Request req) { var requester = new evomatching.ProtocolModels.Matching.ReportDisconnectPlayer(); requester.request.battleServerSessionId = SelfHost.sessionId; requester.request.playerId = req.playerId; var response = await requester.PostAsync(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); var lastBattle = new LastBattle(req.playerId); lastBattle.Model.matchId = (req.forbiddenReturnMatch) ? "" : SelfHost.battleServerInfo.matchId; lastBattle.Model.lastExistedDate = DateTime.UtcNow; await lastBattle.SaveAsync(); var res = new ReportDisconnectPlayer.Response(); res.playerId = req.playerId; return(Ok(res)); }
public override int GetHashCode() { int hash = 1; if (Ret != 0) { hash ^= Ret.GetHashCode(); } if (mainVersion_ != null) { hash ^= MainVersion.GetHashCode(); } if (hotVersion_ != null) { hash ^= HotVersion.GetHashCode(); } hash ^= cacheVersion_.GetHashCode(); hash ^= gameServerInfo_.GetHashCode(); if (imgServerInfo_ != null) { hash ^= ImgServerInfo.GetHashCode(); } if (reserveImgServerInfo_ != null) { hash ^= ReserveImgServerInfo.GetHashCode(); } if (matchingServerInfo_ != null) { hash ^= MatchingServerInfo.GetHashCode(); } hash ^= notice_.GetHashCode(); if (switchControl_ != null) { hash ^= SwitchControl.GetHashCode(); } if (DisclaimerVersion != 0) { hash ^= DisclaimerVersion.GetHashCode(); } return(hash); }
public async Task <IActionResult> CancelPlayer([FromBody] CancelPlayer.Request req) { var requester = new evomatching.ProtocolModels.Matching.CancelPlayer(); requester.request.playerId = SelfHost.playerInfo.playerId; var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } switch (response.Payload.resultCode) { case evomatching.ProtocolModels.Matching.CancelPlayer.Response.ResultCode.Ok: return(Ok(new CancelPlayer.Response())); default: return(BuildErrorResponse(Error.LowCode.CouldNotMatchingCancel)); } }
public static void Main(string[] args) { ThreadPool.SetMinThreads(128, 128); Logger.Initialize(); Logger.Logging( new LogObj().AddChild(new LogModels.ServerStart { Date = DateTime.UtcNow, }) ); var webHost = BuildWebHost(args); while (MasterDataLoader.LatestMasterData == null || !MatchingServerInfo.Ready()) { Thread.Sleep(1000); } webHost.Run(); }
public async Task <IActionResult> SendInvitation([FromBody] SendInvitation.Request req) { var requester = new evomatching.ProtocolModels.PremadeGroup.SendInvitation(); //dst var playerDst = new Player(req.playerId.Value); if (!await playerDst.Validate(PDBSM)) { return(BuildErrorResponse(Error.LowCode.BadParameter)); } requester.request.playerIdDst = playerDst.playerId; requester.request.sessionIdDst = playerDst.Model.sessionId; if (playerDst.Model.matchingArea != SelfHost.matchingArea) { return(BuildErrorResponse(Error.LowCode.PremadeGroupDifferentArea)); } //src requester.request.playerIdSrc = SelfHost.playerInfo.playerId; requester.request.sessionIdSrc = SelfHost.sessionId; if (requester.request.playerIdSrc == requester.request.playerIdDst) { return(BuildErrorResponse(Error.LowCode.BadParameter)); } var response = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(SelfHost.matchingArea)); if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(BuildErrorResponse(Error.LowCode.ServerInternalError)); } switch (response.Payload.resultCode) { case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.Ok: return(Ok(new SendInvitation.Response() { })); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.AlreadyEntrySelf: case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.AlreadyBattleSelf: return(BuildErrorResponse(Error.LowCode.BadRequest)); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.ReceivedInvitationSelf: return(BuildErrorResponse(Error.LowCode.PremadeGroupRecievedInvitationSelf)); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.BusyTarget: return(BuildErrorResponse(Error.LowCode.PremadeGroupTargetBusy)); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.AlreadyGroupTarget: return(BuildErrorResponse(Error.LowCode.PremadeGroupAlreadyGroupTarget)); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.AlreadyEntryTarget: return(BuildErrorResponse(Error.LowCode.PremadeGroupAlreadyEntryTarget)); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.AlreadyBattleTarget: return(BuildErrorResponse(Error.LowCode.PremadeGroupAlreadyBattleTarget)); case evomatching.ProtocolModels.PremadeGroup.SendInvitation.Response.ResultCode.OverLimit: return(BuildErrorResponse(Error.LowCode.PremadeGroupOverLimit)); default: return(BuildErrorResponse(Error.LowCode.Others)); } }
public void MergeFrom(GameServerRes other) { if (other == null) { return; } if (other.Ret != 0) { Ret = other.Ret; } if (other.mainVersion_ != null) { if (mainVersion_ == null) { mainVersion_ = new global::Com.Proto.Server.MainVersionPB(); } MainVersion.MergeFrom(other.MainVersion); } if (other.hotVersion_ != null) { if (hotVersion_ == null) { hotVersion_ = new global::Com.Proto.Server.HotVersionPB(); } HotVersion.MergeFrom(other.HotVersion); } cacheVersion_.Add(other.cacheVersion_); gameServerInfo_.Add(other.gameServerInfo_); if (other.imgServerInfo_ != null) { if (imgServerInfo_ == null) { imgServerInfo_ = new global::Com.Proto.Server.ImgServerInfoPB(); } ImgServerInfo.MergeFrom(other.ImgServerInfo); } if (other.reserveImgServerInfo_ != null) { if (reserveImgServerInfo_ == null) { reserveImgServerInfo_ = new global::Com.Proto.Server.ImgServerInfoPB(); } ReserveImgServerInfo.MergeFrom(other.ReserveImgServerInfo); } if (other.matchingServerInfo_ != null) { if (matchingServerInfo_ == null) { matchingServerInfo_ = new global::Com.Proto.Server.MatchingServiceInfoPB(); } MatchingServerInfo.MergeFrom(other.MatchingServerInfo); } notice_.Add(other.notice_); if (other.switchControl_ != null) { if (switchControl_ == null) { switchControl_ = new global::Com.Proto.Server.SwitchControlPB(); } SwitchControl.MergeFrom(other.SwitchControl); } if (other.DisclaimerVersion != 0) { DisclaimerVersion = other.DisclaimerVersion; } }