private void HandleResponseCustomGameClientConnectionMessage(RestDataRequestMessage message,
                                                                     ResponseCustomGameClientConnectionMessage messageContent, ref RestResponse response,
                                                                     RestRequestMessage request)
        {
            var server = _context.Users.Find(x => x.Id.SessionKey == message.SessionCredentials.SessionKey)
                         .HostedServer;

            foreach (var joindata in messageContent.PlayerJoinData)
            {
                var users = _context.Users.FindAll(usr =>
                                                   joindata.PlayerId.ConvertToPeerId() == usr.Id.PeerId && usr.HostedServer == null);

                switch (joindata.CustomGameJoinResponse)
                {
                case CustomGameJoinResponse.Success:
                    users.ForEach(u =>
                    {
                        u.QueuedMessages.Enqueue(new RestDataResponseMessage(
                                                     JoinCustomGameResultMessage.CreateSuccess(new JoinGameData(
                                                                                                   new GameServerProperties(server.entry.ServerName, server.entry.Address,
                                                                                                                            server.entry.Port, server.Region,
                                                                                                                            server.entry.GameModule, server.entry.GameType, server.entry.Map, "", "",
                                                                                                                            server.entry.MaxPlayerCount,
                                                                                                                            server.entry.IsOfficial), joindata.PeerIndex, joindata.SessionKey))));
                        server.PlayerCount++;
                    });

                    break;

                default:
                    users.ForEach(u =>
                                  u.QueuedMessages.Enqueue(
                                      new RestDataResponseMessage(
                                          JoinCustomGameResultMessage.CreateFailed(joindata.CustomGameJoinResponse))));

                    break;
                }
            }

            response.SetSuccessful(true, "ResultFromServerTask");
        }
Ejemplo n.º 2
0
        private void HandleResponseCustomGameClientConnectionMessage(ResponseCustomGameClientConnectionMessage msg, ref RestResponse response, RestDataRequestMessage message)
        {
            var Server = _context.Users.Find(x => x.Id.SessionKey == message.SessionCredentials.SessionKey).Server;

            foreach (var joindata in msg.PlayerJoinData)
            {
                var users = this._context.Users.FindAll(usr => joindata.PlayerId.ConvertToPeerId() == usr.Id.PeerId && usr.Server == null);
                switch (msg.Response)
                {
                case CustomGameJoinResponse.Success:
                    users.ForEach(u => u.QueuedMessages.Enqueue(new RestDataResponseMessage(JoinCustomGameResultMessage.CreateSuccess(new JoinGameData(new GameServerProperties(Server.ServerName, Server.Address, Server.Port, Server.Region, Server.GameModule, Server.GameType, Server.Map, "", "", Server.MaxPlayerCount, Server.IsOfficial), joindata.PeerIndex, joindata.SessionKey)))));

                    break;

                case CustomGameJoinResponse.IncorrectPlayerState:
                case CustomGameJoinResponse.ServerCapacityIsFull:
                case CustomGameJoinResponse.ErrorOnGameServer:
                case CustomGameJoinResponse.GameServerAccessError:
                case CustomGameJoinResponse.CustomGameServerNotAvailable:
                case CustomGameJoinResponse.CustomGameServerFinishing:
                case CustomGameJoinResponse.IncorrectPassword:
                case CustomGameJoinResponse.PlayerBanned:
                case CustomGameJoinResponse.HostReplyTimedOut:
                case CustomGameJoinResponse.NoPlayerDataFound:
                case CustomGameJoinResponse.UnspecifiedError:
                case CustomGameJoinResponse.NoPlayersCanJoin:
                case CustomGameJoinResponse.AlreadyRequestedWaitingForServerResponse:
                case CustomGameJoinResponse.RequesterIsNotPartyLeader:
                case CustomGameJoinResponse.NotAllPlayersReady:
                default:
                    users.ForEach(u => u.QueuedMessages.Enqueue(new RestDataResponseMessage(JoinCustomGameResultMessage.CreateFailed(msg.Response))));

                    break;
                }
            }
            response.SetSuccessful(true, "ResultFromServerTask");
        }