示例#1
0
 private void JoinEventHandler(UdpSession session)
 {
     if (BoltNetwork.IsClient)
     {
         BoltMatchmaking.JoinSession(session);
     }
 }
示例#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);
                }
            }
        }
示例#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();
            }
        }
示例#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());
 }
示例#5
0
        public override void ConnectToSession(INetworkInterfaceSession session, OperationResultDelegate onComplete)
        {
            _operationCallbackSessionConnected = onComplete;

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

            BoltMatchmaking.JoinSession(udpSession);

            _connectedSessionInfo = session;
        }
示例#6
0
文件: Menu.cs 项目: manhiem/Scribble
 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);
         }
     }
 }
示例#7
0
 public override void BoltStartDone()
 {
     if (BoltNetwork.IsServer)
     {
         currentSession = PlayerPrefs.GetString("currentSession");
         BoltMatchmaking.CreateSession(sessionID: currentSession, sceneToLoad: "FPSGame");
     }
     else
     {
         BoltMatchmaking.JoinSession(currentSession);
     }
 }
示例#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);
    }
示例#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);
            }
        }
    }
示例#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();
            }
        }
示例#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");
    }
示例#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();
        }
    }
示例#13
0
 private void JoinGame(UdpSession photonSession)
 {
     BoltMatchmaking.JoinSession(photonSession);
 }
示例#14
0
 private void OnClickJoinGame(PhotonSession photonSession)
 {
     BoltMatchmaking.JoinSession(photonSession);
 }
示例#15
0
 public void JoinGame(UdpSession PhotonSession)
 {
     BoltMatchmaking.JoinSession(PhotonSession);
 }
 public override void SessionListUpdated(Map <Guid, UdpSession> sessionList)
 {
     FeedbackUser("Searching ...");
     BoltMatchmaking.JoinSession(HeadlessServerManager.RoomID());
 }
 public void StartSession()
 {
     BoltMatchmaking.JoinSession(sessionObject);
 }
 private void JoinWithSessionName()
 {
     BoltMatchmaking.JoinSession(joinServerSessionIdInputField.text);
 }
示例#19
0
 public void JoinSession() => BoltMatchmaking.JoinSession(SessionInput.text);
示例#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();
        }