Beispiel #1
0
        private IEnumerator WaitConnected(ResultConnect finishHandler)
        {
            var result      = false;
            var loop        = true;
            var joinedLobby = new EventHandler((s, a) =>
            {
                loop   = false;
                result = true;
            });

            _cancelConnected = false;
            PhotonServer.JoinedLobbyEvent += joinedLobby;
            if (PhotonServer.Connect())
            {
                loop   = false;
                result = true;
            }
            while (loop)
            {
                yield return(null);

                if (!_cancelConnected)
                {
                    continue;
                }
                loop = false;
                PhotonServer.Disconnect();
            }
            PhotonServer.JoinedLobbyEvent -= joinedLobby;

            if (finishHandler != null)
            {
                finishHandler(result);
            }
        }