public void ConnectToSession(INetworkInterfaceSession session, Action <bool, string> onComplete = null)
    {
        IsConnectingSession = true;

        _onConnectToSessionsCallback = onComplete;
        _network.ConnectToSession(session, OnConnectToSessionComplete);
    }
예제 #2
0
        public override void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete)
        {
            _operationCallbackSessionConnected = onComplete;

            UdpSession udpSession = ((PhotonNetworkInterfaceSession)session).UdpSession;

            BoltMatchmaking.JoinSession(udpSession);

            _connectedSessionInfo = session;
        }
예제 #3
0
    void UpdateSessionButtonList()
    {
        bool oneItemIsSelected = false;

        // update existing buttons and add new ones
        for (int i = 0; i < _sessions.Count; i++)
        {
            if (i == _sessionButtons.Count)
            {
                // create new button!
                SessionButton newButton = Instantiate(_sessionButtonPrefab, _sessionButtonContainer);
                newButton.onClick += OnSessionButtonClick;
                _sessionButtons.Add(newButton);
            }

            _sessionButtons[i].session  = _sessions[i];
            _sessionButtons[i].selected = _selectedSession != null && (_selectedSession.Id == _sessions[i].Id);
            if (_sessionButtons[i].selected)
            {
                oneItemIsSelected = true;
            }
        }

        // remove extra buttons
        for (int r = _sessionButtons.Count - 1; r >= _sessions.Count; r--)
        {
            _sessionButtons[r].DestroyGO();
            _sessionButtons.RemoveLast();
        }

        if (oneItemIsSelected == false)
        {
            // we were focusing a session that does not exist anymore
            _selectedSession = null;
        }
    }
예제 #4
0
    static IEnumerator StartClient(QuickStartSettings settings)
    {
        LoadingScreenUIController.DisplayedStatus = "Waiting for online services...";

        OnlineService.SetTargetRole(OnlineRole.Client);
        while (OnlineService.IsChangingRole ||
               OnlineService.CurrentRole != OnlineRole.Client ||
               OnlineService.ClientInterface == null)
        {
            yield return(null);
        }

        if (string.IsNullOrEmpty(settings.serverName))
        {
            LoadingScreenUIController.DisplayedStatus = "Loading...";
            GameStateManager.TransitionToState(Assets.lobbyClient);
        }
        else
        {
            LoadingScreenUIController.DisplayedStatus = "Looking for server [" + settings.serverName + "] ...";

            INetworkInterfaceSession foundSession = null;

            IEnumerator WaitForServerToAppear()
            {
                float elapsedTime = 0;

                while (foundSession == null &&
                       (elapsedTime < Assets.searchForSeverTimeout || Assets.searchForSeverTimeout == -1) &&
                       OnlineService.ClientInterface != null)
                {
                    foreach (INetworkInterfaceSession session in OnlineService.ClientInterface.AvailableSessions)
                    {
                        if (session.HostName == settings.serverName)
                        {
                            foundSession = session;
                            break;
                        }
                    }
                    elapsedTime += Time.unscaledDeltaTime;
                    yield return(null);
                }
            }

            yield return(WaitForServerToAppear());

            if (foundSession == null)
            {
                string message = "Failed client quickstart. Could not find server with name [" + settings.serverName + "] in time.";
                DebugScreenMessage.DisplayMessage(message);
                Log.Warning(message);
                GameStateManager.TransitionToState(Assets.rootMenu);
            }
            else
            {
                LoadingScreenUIController.DisplayedStatus = "Connecting to server [" + settings.serverName + "] ...";

                int success = -1; // -1 -> waiting for result    0 -> failure        1 -> success
                OnlineService.ClientInterface.ConnectToSession(foundSession, (bool r, string message) =>
                {
                    if (r)
                    {
                        success = 1;
                    }
                    else
                    {
                        success = 0;
                    }
                });

                // wait for connection result
                while (success == -1)
                {
                    yield return(null);
                }

                if (success == 0)
                {
                    string message = "Failed client quickstart. Could not connect to server [" + settings.serverName + "].";
                    DebugScreenMessage.DisplayMessage(message);
                    Log.Error(message);

                    GameStateManager.TransitionToState(Assets.rootMenu);
                }
                else
                {
                    // success!
                    LoadingScreenUIController.DisplayedStatus = "Loading...";
                    GameStateManager.TransitionToState(Assets.inGameClient);
                }
            }
        }
    }
예제 #5
0
 void OnSessionButtonClick(SessionButton button)
 {
     _selectedSession = button.session;
     UpdateSessionButtonList();
 }
 public abstract void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete = null);
#pragma warning restore CS0067 // Naming Styles

    public override void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete = null)
    {
        throw new NotImplementedException();
    }
 public void JoinSession(INetworkInterfaceSession session, Action <bool, string> callback)
 {
     _joinSessionCallback = callback;
     WaitSpinnerService.Enable(this);
     OnlineService.ClientInterface.ConnectToSession(session, OnJoinSessionResult);
 }