Пример #1
0
    /// <summary>
    /// The event that occurs when we received the status of joining the lobby. This is a follow-up of Update_Search().
    /// </summary>
    protected void Search_Post(bool isSuccess)
    {
        // Stop Update_Search() from being invoked.
        mUpdate_joinStatus = JoinStatus.None;

        if (isSuccess)
        {
            HideLoadingSplash();

            if (mMP_Mode == NetworkType.InternetIP)
            {
                mLobbyMenu_lobbyCodeWithHeaderText.text = "Lobby IP: " + mLobbyCode;
            }
            else
            {
                mLobbyMenu_lobbyCodeWithHeaderText.text = "Lobby Room Code: " + mLobbyCode;
            }

            SwitchMenu(mLobbyMenu);
            mLobby.JoinLobby_ToggleLobbyClientLogic(true);
        }
        else
        {
            UpdateLoadingSplashMessage("Failed to join lobby.");
            RevealCloseLoadingSplashButton();
        }
    }
Пример #2
0
 public JoinInfo(string serverIpAddress, ushort serverPort, Guid roomId, JoinStatus status, int currentPlayers, int maxPlayers, bool joinToExisting = false)
 {
     ServerIpAddress = serverIpAddress;
     ServerPort      = serverPort;
     RoomId          = roomId;
     Status          = status;
     CurrentPlayers  = currentPlayers;
     MaxPlayers      = maxPlayers;
     JoinToExisting  = joinToExisting;
 }
Пример #3
0
        public async Task RespondToGroupJoinRequest(long groupId, long userId, JoinStatus status)
        {
            if (status == JoinStatus.accepted)
            {
                GroupUser groupUser = new GroupUser
                {
                    GroupId = groupId,
                    UserId  = userId,
                    Role    = Role.user
                };

                _context.GroupUsers.Add(groupUser);
                await _context.SaveChangesAsync();
            }

            var joinRequest = await _context.JoinRequests.FindAsync(groupId, userId);

            _context.JoinRequests.Remove(joinRequest);
            await _context.SaveChangesAsync();
        }
Пример #4
0
    /* 4.5 - Client - Enter Lobby Code Menu */

    /// <summary>
    /// Event that occurs when the "Search" button is pressed. The specified lobby will be queried and joined.
    /// </summary>
    public void OnClick_Search()
    {
        mLobbyCode = mClientEnterLobbyCodeMenu_codeField.text;
        if (mIsDebug)
        {
            Debug.Log("OnClick_Search(): Lobby Code - " + mLobbyCode);
        }

        ShowLoadingSplash("Searching lobby...");

        // Start the timer.
        mUpdate_nextTime = Time.time + mUpdate_intervalTime;
        mUpdate_endTime  = Time.time + mUpdate_maxDuration;
        if (mMP_Mode == NetworkType.LocalWifiDirect)
        {
            mUpdate_endTime += mUpdate_maxDuration_wifidirect_ext;
        }

        mLobby.Disconnect(mIsHost, mMP_Mode);
        mUpdate_joinStatus = JoinStatus.Disconnected;
    }
Пример #5
0
 private static extern int NetGetJoinInformation(string computerName, out IntPtr buffer, out JoinStatus status);
Пример #6
0
        public async Task <ActionResult> RequestToJoinGroupResponse(long groupId, long userId, JoinStatus status)
        {
            GroupUser currentUser = await guRepo.GetGroupUser(groupId, UserId);

            Role role = currentUser.Role;

            var userInGroup = guRepo.GetGroupUser(groupId, userId);

            if (userInGroup == null)
            {
                return(BadRequest("That user is already in the group. Something went wrong."));
            }

            if (role == Role.owner || role == Role.admin)
            {
                await repository.RespondToGroupJoinRequest(groupId, userId, status);

                return(Ok());
            }
            else
            {
                return(Unauthorized("Only admins or owners can respond to join requests. Please talk to the groups admins if you believe this to be a mistake."));
            }
        }
Пример #7
0
    /// <summary>
    /// This is called by Update() repeatedly to inquire the status of the success of joining the lobby. This function
    /// is only triggered if OnClick_Search() is called.
    /// </summary>
    protected void Update_JoiningLobby()
    {
        if (mUpdate_joinStatus == JoinStatus.None)
        {
            return;
        }

        if (Time.time > mUpdate_endTime)
        {
            if (mUpdate_joinStatus == JoinStatus.NetworkStarted)
            {
                mLobby.JoinLobby_DisposeNetworkManager();
            }

            // Timeout. Report Failure.
            Search_Post(false);
            return;
        }
        else if (Time.time > mUpdate_nextTime)
        {
            if (mUpdate_joinStatus == JoinStatus.Disconnected)
            {
                string result = mLobby.DisconnectResult();
                if (result == null)
                {
                    ;                     // Try again later.
                }
                else if (result == "failure")
                {
                    Search_Post(false);                          // Report failure.
                }
                else
                {
                    // Success. Next phase.
                    mLobby.JoinLobby_DiscoverIP(mMP_Mode, mLobbyCode);
                    mUpdate_joinStatus = JoinStatus.NetworkStarting;
                }
            }
            else if (mUpdate_joinStatus == JoinStatus.NetworkStarting)
            {
                bool?rv = mLobby.JoinLobby_StartNetworkManager();
                if (rv == null)
                {
                    ;                       // Try again later.
                }
                else if (rv == true)
                {
                    mUpdate_joinStatus = JoinStatus.NetworkStarted;                             // Success. Next phase.
                }
                else
                {
                    Search_Post(false);                                 // Report failure.
                }
            }
            else if (mUpdate_joinStatus == JoinStatus.NetworkStarted)
            {
                bool?rv = mLobby.JoinLobby_ConnectResult();
                if (rv == null)
                {
                    ;                       // Try again later.
                }
                else if (rv == true)
                {
                    Search_Post(true);                                  // Report success.
                }
                else
                {
                    Search_Post(false);                                 // Report failure.
                }
            }

            mUpdate_nextTime = Time.time + mUpdate_intervalTime;
        }
    }
Пример #8
0
 public JoinResponse(JoinStatus status) : base("join")
 {
     Status = status;
 }