Esempio n. 1
0
        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,
            }));
        }
Esempio n. 2
0
        public IActionResult ForceMatchmake(
            [FromBody] ForceMatchmake.Request req, [FromServices] GeneralManager gm)
        {
            gm.EnqueueJob(async() =>
            {
                var match = gm.MatchManager.GetMatch(req.matchId);

                var newPlayers = new Dictionary <string, long>();

                for (int i = 0; i < req.entries.Count; i++)
                {
                    var entry = gm.BattleEntryManager.GetEntry(req.entries[i].entryId);
                    if (entry == null)
                    {
                        continue;
                    }

                    var side = req.entries[i].side;

                    if (gm.MatchManager.AssignPlayers(req.matchId, entry.Players, side))
                    {
                        gm.BattleEntryManager.Cancel(entry.EntryId, req.matchId, evolib.BattleEntry.Type.Matching);

                        for (int j = 0; j < entry.Players.Count; j++)
                        {
                            var p = entry.Players[j];
                            newPlayers[p.SessionId] = p.PlayerId;
                        }
                    }
                }

                foreach (var p in newPlayers)
                {
                    await new ConnectionQueue(p.Key).EnqueueAsync(match.JoinBattleServer(p.Value));
                }

                await new ConnectionQueue(match.Server.SessionId).EnqueueAsync(match.MatchInfo());
            });

            var res = new ForceMatchmake.Response();

            return(Ok(res));
        }