Exemplo n.º 1
0
 private void JoinEventHandler(UdpSession session)
 {
     if (BoltNetwork.IsClient)
     {
         BoltMatchmaking.JoinSession(session);
     }
 }
Exemplo n.º 2
0
        public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
        {
            if (_timerRoutine != null)
            {
                StopCoroutine(_timerRoutine);
                _timerRoutine = null;
            }

            Debug.LogFormat("Session list updated: {0} total sessions", sessionList.Count);

            foreach (var session in sessionList)
            {
                PhotonSession photonSession = session.Value as PhotonSession;

                if (photonSession != null && photonSession.Source == UdpSessionSource.Photon)
                {
                    object value;
                    if (photonSession.Properties.TryGetValue("type", out value))
                    {
                        BoltLog.Info("Room with type: {0}", value);
                    }

                    if (photonSession.Properties.TryGetValue("map", out value))
                    {
                        BoltLog.Info("Room with map: {0}", value);
                    }

                    BoltMatchmaking.JoinSession(photonSession);
                }
            }
        }
Exemplo n.º 3
0
        void State_SelectRoom()
        {
            GUI.Label(labelRoom, "Looking for rooms:", labelRoomStyle);

            if (BoltNetwork.SessionList.Count > 0)
            {
                GUILayout.BeginVertical();
                GUILayout.Space(30);

                foreach (var session in BoltNetwork.SessionList)
                {
                    var photonSession = session.Value as PhotonSession;

                    if (photonSession.Source == UdpSessionSource.Photon)
                    {
                        var matchName = photonSession.HostName;
                        var label     = string.Format("Join: {0} | {1}/{2}", matchName, photonSession.ConnectionsCurrent, photonSession.ConnectionsMax);

                        if (ExpandButton(label))
                        {
                            BoltMatchmaking.JoinSession(photonSession);
                            state = State.Started;
                        }
                    }
                }

                GUILayout.EndVertical();
            }
        }
Exemplo n.º 4
0
 public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
 {
     FeedbackUser("Searching ...");
     //On rejoin le seul server qui existe pour le moment
     //Vu que le server est dans PlayScene on va essayer de load ca
     BoltMatchmaking.JoinSession(HeadlessServerManager1.RoomID());
 }
Exemplo n.º 5
0
        public override void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete)
        {
            _operationCallbackSessionConnected = onComplete;

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

            BoltMatchmaking.JoinSession(udpSession);

            _connectedSessionInfo = session;
        }
Exemplo n.º 6
0
 public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
 {
     foreach (var session in sessionList)
     {
         UdpSession photonSession = session.Value as UdpSession;
         if (photonSession.Source == UdpSessionSource.Photon)
         {
             BoltMatchmaking.JoinSession(photonSession);
         }
     }
 }
Exemplo n.º 7
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         currentSession = PlayerPrefs.GetString("currentSession");
         BoltMatchmaking.CreateSession(sessionID: currentSession, sceneToLoad: "FPSGame");
     }
     else
     {
         BoltMatchmaking.JoinSession(currentSession);
     }
 }
Exemplo n.º 8
0
    public void StartClient()
    {
        string playerName = joinPlayerName.GetComponent <UnityEngine.UI.Text>().text;
        string matchName  = joinname.GetComponent <UnityEngine.UI.Text>().text;

        if (string.IsNullOrWhiteSpace(playerName) || string.IsNullOrWhiteSpace(matchName))
        {
            return;
        }

        NetworkCallbacks.playerName = playerName;
        BoltMatchmaking.JoinSession(matchName);
    }
Exemplo n.º 9
0
    public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
    {
        Debug.LogFormat("Session list updated: {0} total sessions", sessionList.Count);

        foreach (var session in sessionList)
        {
            UdpSession photonSession = session.Value as UdpSession;

            if (photonSession.Source == UdpSessionSource.Photon)
            {
                BoltMatchmaking.JoinSession(photonSession);
            }
        }
    }
Exemplo n.º 10
0
        void State_SelectRoom()
        {
            GUI.Label(labelRoom, string.Format("Looking for rooms ({0}):", 5000 - watch.ElapsedMilliseconds), labelRoomStyle);

            if (BoltNetwork.SessionList.Count > 0)
            {
                if (watch.IsRunning == false)
                {
                    BoltLog.Warn("Start connect timer");
                    autoConnect = false;
                    watch.Start();
                }

                if (watch.ElapsedMilliseconds > 5000)
                {
                    autoConnect = true;
                }

                GUILayout.BeginVertical();
                GUILayout.Space(30);

                foreach (var session in BoltNetwork.SessionList)
                {
                    var photonSession = session.Value as PhotonSession;

                    if (photonSession.Source == UdpSessionSource.Photon)
                    {
                        var matchName = photonSession.HostName;
                        var label     = string.Format("Join: {0} | {1}/{2} | {3}", matchName, photonSession.ConnectionsCurrent, photonSession.ConnectionsMax, photonSession.IsOpen ? "Open" : "Closed");

                        if ((ExpandButton(label) || autoConnect) && photonSession.IsOpen)
                        {
                            BoltMatchmaking.JoinSession(photonSession);

                            autoConnect = false;
                            watch.Stop();
                            watch.Reset();
                        }
                    }
                }

                GUILayout.EndVertical();
            }
            else
            {
                watch.Stop();
                watch.Reset();
            }
        }
Exemplo n.º 11
0
    public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
    {
        Debug.Log($"Session List Updated, found {sessionList.Count} session");

        foreach (var session in sessionList)
        {
            UdpSession photonSession = session.Value as UdpSession;

            if (photonSession.Source == UdpSessionSource.Photon)
            {
                BoltMatchmaking.JoinSession(photonSession);
            }
        }
        Debug.Log("The whole list is invalid");
    }
Exemplo n.º 12
0
    private void SelectRoom()
    {
        GUI.Label(_labelRoom, "Looking for rooms:", _labelRoomStyle);

        if (BoltNetwork.SessionList.Count > 0)
        {
            GUILayout.BeginVertical();
            GUILayout.Space(30);

            foreach (var session in BoltNetwork.SessionList)
            {
                UdpSession udpSession = session.Value;

                var label = string.Format("Join: {0} | {1}", udpSession.HostName, udpSession.Source);

                if (ExpandButton(label))
                {
                    BoltMatchmaking.JoinSession(udpSession);
                }
            }

            GUILayout.EndVertical();
        }
    }
Exemplo n.º 13
0
 private void JoinGame(UdpSession photonSession)
 {
     BoltMatchmaking.JoinSession(photonSession);
 }
Exemplo n.º 14
0
 private void OnClickJoinGame(PhotonSession photonSession)
 {
     BoltMatchmaking.JoinSession(photonSession);
 }
Exemplo n.º 15
0
 public void JoinGame(UdpSession PhotonSession)
 {
     BoltMatchmaking.JoinSession(PhotonSession);
 }
Exemplo n.º 16
0
 public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
 {
     FeedbackUser("Searching ...");
     BoltMatchmaking.JoinSession(HeadlessServerManager.RoomID());
 }
Exemplo n.º 17
0
 public void StartSession()
 {
     BoltMatchmaking.JoinSession(sessionObject);
 }
 private void JoinWithSessionName()
 {
     BoltMatchmaking.JoinSession(joinServerSessionIdInputField.text);
 }
Exemplo n.º 19
0
 public void JoinSession() => BoltMatchmaking.JoinSession(SessionInput.text);
Exemplo n.º 20
0
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(10, 10, Screen.width - 20, Screen.height - 20));

            switch (_state)
            {
            // starting Bolt is the same regardless of the transport layer
            case State.SelectMode:
                if (GUILayout.Button("Start Server", GUILayout.ExpandWidth(true)))
                {
                    BoltLauncher.StartServer();
                    _state = State.ModeServer;
                }

                if (GUILayout.Button("Start Client", GUILayout.ExpandWidth(true)))
                {
                    BoltLauncher.StartClient();
                    _state = State.ModeClient;
                }

                break;

            // Publishing a session into the matchmaking server
            case State.ModeServer:
                if (BoltNetwork.IsRunning && BoltNetwork.IsServer)
                {
                    if (GUILayout.Button("Publish HostInfo And Load Map", GUILayout.ExpandWidth(true)))
                    {
                        // RoomProtocolToken token = new RoomProtocolToken()
                        // {
                        //  ArbitraryData = "My DATA",
                        //  password = "******"
                        // };

                        // Uncomment if you want to pass custom properties into your room
                        // This is just an example data
                        //PhotonCloudRoomProperties token = new PhotonCloudRoomProperties();
                        //properties.AddRoomProperty("t", 1);
                        //properties.AddRoomProperty("m", 4);

                        PhotonRoomProperties token = new PhotonRoomProperties();
                        token.IsOpen    = true;
                        token.IsVisible = true;

                        token.AddRoomProperty("t", 1);
                        token.AddRoomProperty("m", 2);

                        string matchName = "MyPhotonGame #" + UnityEngine.Random.Range(1, 100);

                        BoltMatchmaking.CreateSession(
                            sessionID: matchName,
                            token: token,
                            sceneToLoad: "PhotonGame"
                            );
                    }
                }
                break;

            // for the client, after Bolt is innitialized, we should see the list
            // of available sessions and join one of them
            case State.ModeClient:

                if (BoltNetwork.IsRunning && BoltNetwork.IsClient)
                {
                    GUILayout.Label("Session List");

                    foreach (var session in BoltNetwork.SessionList)
                    {
                        // Simple session
                        UdpSession udpSession = session.Value as UdpSession;

                        // Skip if is not a Photon session
                        if (udpSession.Source != UdpSessionSource.Photon)
                        {
                            continue;
                        }

                        // Photon Session
                        PhotonSession photonSession = udpSession as PhotonSession;

                        string sessionDescription = String.Format("{0} / {1} ({2})",
                                                                  photonSession.Source, photonSession.HostName, photonSession.Id);

                        RoomProtocolToken token = photonSession.GetProtocolToken() as RoomProtocolToken;

                        if (token != null)
                        {
                            sessionDescription += String.Format(" :: {0}", token.ArbitraryData);
                        }
                        else
                        {
                            object value_t = -1;
                            object value_m = -1;

                            if (photonSession.Properties.ContainsKey("t"))
                            {
                                value_t = photonSession.Properties["t"];
                            }

                            if (photonSession.Properties.ContainsKey("m"))
                            {
                                value_m = photonSession.Properties["m"];
                            }

                            sessionDescription += String.Format(" :: {0}/{1}", value_t, value_m);
                        }

                        if (GUILayout.Button(sessionDescription, GUILayout.ExpandWidth(true)))
                        {
                            ServerConnectToken connectToken = new ServerConnectToken
                            {
                                data = "ConnectTokenData"
                            };

                            BoltMatchmaking.JoinSession(photonSession, connectToken);
                        }
                    }
                }
                break;
            }

            GUILayout.EndArea();
        }