Connect() private méthode

private Connect ( string serverAddress, int port, string uniqueGameID ) : void
serverAddress string
port int
uniqueGameID string
Résultat void
    public void ConnectToPhoton()
    {
        if (PhotonNetwork.connected)
        {
            Debug.LogError("cannot switch server when connect");
        }

        Debug.Log(PhotonNetwork.playerName);

        PhotonNetwork.PhotonServerSettings.ServerAddress =
            PhotonNetwork.PhotonServerSettings._serverAddressList[MultiplayerDataManager.Instance.PhotonServerSelectIndex];

        PhotonNetwork.networkingPeer.CrcEnabled = true;
        PhotonNetwork.SwitchToProtocol(PhotonNetwork.PhotonServerSettings.ConnectionProtocol);
        //PhotonNetwork.PhotonServerSettings.ServerPort = 4530;

        string gameVersion = string.Empty;

#if DEVELOPMENT_BUILD
        gameVersion = FCConst.PHOTON_CONNECT_VERSION_STAGE;
#else
        gameVersion = FCConst.PHOTON_CONNECT_VERSION_LIVE;
#endif
        PhotonNetwork.Connect(PhotonNetwork.PhotonServerSettings.ServerAddress,
                              PhotonNetwork.PhotonServerSettings.ServerPort,
                              PhotonNetwork.PhotonServerSettings.AppID,
                              gameVersion);


        //	PhotonNetwork.ConnectUsingSettings("0.0.1");
    }
        public override void OnEnter()
        {
            PhotonNetwork.Connect(serverAddress.Value, port.Value, applicationID.Value, clientGameVersion.Value);

            // reset authentication failure properties.
            PlayMakerPhotonProxy.lastAuthenticationDebugMessage = string.Empty;
            PlayMakerPhotonProxy.lastAuthenticationFailed       = false;

            Finish();
        }
Exemple #3
0
    IEnumerator ConnectToBestRegionInternal(string gameVersion)
    {
        while (isPinging)
        {
            yield return(0); // wait until pinging finished (offline mode won't ping)
        }

        ServerSettings settings = (ServerSettings)Resources.Load(PhotonNetwork.serverSettingsAssetFile, typeof(ServerSettings));

        if (settings.HostType == ServerSettings.HostingOption.OfflineMode)
        {
            PhotonNetwork.ConnectUsingSettings(gameVersion);
        }
        else
        {
            PhotonNetwork.Connect(ServerSettings.FindServerAddressForRegion(closestRegion), settings.ServerPort, settings.AppID, gameVersion);
        }
    }
    IEnumerator Connect()
    {
        if (txtServerIP.text != "")
        {
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
            //while (YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.PeerState != ExitGames.Client.Photon.PeerStateValue.Disconnected)
            //{
            //    yield return new WaitForSeconds(1);
            //}
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerAddress = txtServerIP.text + ":5059";
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().Connect();
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer = new ExitGames.Client.Photon.PhotonPeer(YuanUnityPhoton.GetYuanUnityPhotonInstantiate());
            //YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Connect(txtServerIP.text+":5059", "YuanPhotonServerRoom");
            //InRoom.GetInRoomInstantiate().peer.Disconnect();
            //InRoom.GetInRoomInstantiate().peer = new ExitGames.Client.Photon.PhotonPeer(InRoom.GetInRoomInstantiate());

            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().peer.Disconnect();
            YuanUnityPhoton.NewYuanUnityPhotonInstantiate().ServerAddress = txtServerIP.text + ":5059";
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().MMManage      = this.mmManage;
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().tableRead     = this.tableRead;
            YuanUnityPhoton.GetYuanUnityPhotonInstantiate().Connect();
            InRoom.GetInRoomInstantiate().peer.Disconnect();
            InRoom.NewInRoomInstantiate();
            //InRoom.GetInRoomInstantiate().Connect();

            ServerSettings.DefaultServerAddress = txtServerIP.text + ":5055";
            PhotonNetwork.Disconnect();
            while (PhotonNetwork.connectionState != ConnectionState.Disconnected)
            {
                yield return(new WaitForSeconds(0.5f));
            }
            PhotonNetwork.Connect(txtServerIP.text, 5055, "Master", "1.0");
            PlayerPrefs.SetString("TestServer", txtServerIP.text);
            PlayerPrefs.SetString("TestServerName", "YuanPhotonServerRoom");
        }
    }
 public override void OnEnter()
 {
     PhotonNetwork.Connect(serverAddress.Value, port.Value, applicationID.Value, clientGameVersion.Value);
     Finish();
 }