Пример #1
0
        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,
            }));
        }
Пример #2
0
        public async Task <IActionResult> GetEntries(
            [FromBody] GetEntries.Request req, [FromServices] GeneralManager gm)
        {
            var res = new GetEntries.Response();

            res.battleServers = new List <GetEntries.Response.BattleServer>();
            res.entries       = new List <GetEntries.Response.Entry>();

            await gm.EnqueueJob(() =>
            {
                var allMatches = gm.MatchManager.GatherMatches(m => true);

                foreach (var match in allMatches)
                {
                    var sv = new GetEntries.Response.BattleServer
                    {
                        matchId = match.MatchId,
                        state   = (int)match.State,

                        sessionId           = match.Server.SessionId,
                        ipAddr              = match.Server.IpAddr,
                        port                = match.Server.Port,
                        rule                = match.Server.Rule,
                        mapId               = match.Server.MapId,
                        label               = match.Server.Label,
                        description         = match.Server.Description,
                        serverName          = match.Server.ServerName,
                        region              = match.Server.Region,
                        owner               = match.Server.Owner,
                        autoMatchmakeTarget = match.Server.AutoMatchmakeTarget,

                        players = new List <GetEntries.Response.BattleServer.Player>(),
                    };

                    for (int i = 0; i < match.Players.Count; i++)
                    {
                        var p = match.Players[i];
                        sv.players.Add(new GetEntries.Response.BattleServer.Player
                        {
                            playerId   = p.PlayerId,
                            playerName = p.PlayerName,
                            rating     = p.Rating,
                            groupNo    = p.GroupNo,
                            side       = p.Side,
                        });
                    }

                    res.battleServers.Add(sv);
                }

                var allEntries = gm.BattleEntryManager.GetEntries(e => true);
                foreach (var src in allEntries)
                {
                    var dst = new GetEntries.Response.Entry
                    {
                        entryId   = src.EntryId,
                        matchType = src.MatchType,
                        rating    = src.RatingAvg,
                        players   = new List <GetEntries.Response.EntryPlayer>(),
                    };

                    for (int i = 0; i < src.Players.Count; i++)
                    {
                        var p = src.Players[i];
                        dst.players.Add(new GetEntries.Response.EntryPlayer
                        {
                            playerId   = p.PlayerId,
                            playerName = p.PlayerName,
                            rating     = p.Rating,
                        });
                    }

                    res.entries.Add(dst);
                }
            });

            return(Ok(res));
        }