Exemplo n.º 1
0
        public async Task <IJResponse> AdvertiseHeartbeat(
            [FromServices] IServerRepository serverRepository,
            [FromBody] JAdvertiseHeartbeatRequest body)
        {
            Server server = await serverRepository.GetByToken(body.token);

            if (server == null)
            {
                return(JResponse.Error("Server not registered."));
            }

            server.Players       = body.players;
            server.GameInfo      = body.gameInfo;
            server.LastHeartbeat = DateTime.Now;
            await serverRepository.AddOrUpdate(server);

            return(ConvertResponse(JResponse.OK()));
        }