// @TODO:  ClientWantsToConnectCustomGameMessage
        private void HandleRequestJoinCustomGameMessage(RestDataRequestMessage message,
                                                        RequestJoinCustomGameMessage messageContent,
                                                        ref RestResponse response, RestRequestMessage request)
        {
            User ServerOwner = _context.FindServerHosterBy(messageContent.CustomBattleId);

            User JoiningUser = _context.FindUserBySessionCredentials(message.SessionCredentials);

            if (ServerOwner == default || JoiningUser == default)
            {
                return;
            }
            if (ServerOwner.HostedServer == null)
            {
                return;
            }


            /*@TODO:
             *  //var result =  JoinCustomGameResultMessage.CreateSuccess(new JoinGameData(properties,0,0 ));
             *  ServerOwner.QueuedMessages.Add(new ClientWantsToConnectCustomGameMessage(new PlayerJoinGameData[]{new PlayerJoinGameData(JoiningUser.PlayerData,JoiningUser.PlayerData.LastPlayerName) },msg.Password ));
             *
             *  response.EnqueueMessage(new RestDataResponseMessage(result));
             */
            ServerOwner.QueuedMessages.Enqueue(new RestDataResponseMessage(
                                                   new ClientWantsToConnectCustomGameMessage(
                                                       new[]
                                                       { new PlayerJoinGameData(JoiningUser.PlayerData, JoiningUser.PlayerData.LastPlayerName, null) },
                                                       messageContent.Password)));

            response.SetSuccessful(true, "ResultFromServerTask");
        }
Пример #2
0
        // @TODO:  ClientWantsToConnectCustomGameMessage
        private void HandleRequestJoinCustomGameMessage(RequestJoinCustomGameMessage msg, ref RestResponse response, RestDataRequestMessage message)
        {
            User ServerOwner = _context.Users.Find(user => user.Server?.Id.Guid == msg.CustomBattleId.Guid);
            User JoiningUser = _context.Users.Find(user => user.Id.PeerId == message.SessionCredentials.PeerId);

            if (ServerOwner.Server != null)
            {
                var properties = new GameServerProperties(ServerOwner.Server.ServerName, ServerOwner.Server.Address, ServerOwner.Server.Port, ServerOwner.Server.Region, ServerOwner.Server.GameModule, ServerOwner.Server.GameType, ServerOwner.Server.Map, "", "", ServerOwner.Server.MaxPlayerCount, ServerOwner.Server.IsOfficial);

                /*@TODO:
                 * //var result =  JoinCustomGameResultMessage.CreateSuccess(new JoinGameData(properties,0,0 ));
                 * ServerOwner.QueuedMessages.Add(new ClientWantsToConnectCustomGameMessage(new PlayerJoinGameData[]{new PlayerJoinGameData(JoiningUser.PlayerData,JoiningUser.PlayerData.LastPlayerName) },msg.Password ));
                 *
                 * response.EnqueueMessage(new RestDataResponseMessage(result));
                 */
                ServerOwner.QueuedMessages.Enqueue(new RestDataResponseMessage(new ClientWantsToConnectCustomGameMessage(new PlayerJoinGameData[] { new PlayerJoinGameData(JoiningUser.PlayerData, JoiningUser.PlayerData.LastPlayerName) }, msg.Password)));

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