Example #1
0
        private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
        {
            var listner = new PhotonListener(false);
            var peer    = new PhotonPeer(listner, protocol);

            if (!peer.Connect(serverAddress, appId))
            {
                return(false);
            }

            var counter = 100;

            while (--counter > 0)
            {
                peer.Service();
                if (listner.WaitForConnection(0))
                {
                    var res = peer.PeerState == PeerStateValue.Connected;
                    peer.Disconnect();
                    return(res);
                }
                Thread.Sleep(50);
            }
            return(false);
        }
Example #2
0
        private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
        {
            var listner = new PhotonListener(false);
            var peer = new PhotonPeer(listner, protocol);

            if (!peer.Connect(serverAddress, appId))
            {
                return false;
            }

            var counter = 100;
            while (--counter > 0)
            {
                peer.Service();
                if (listner.WaitForConnection(0))
                {
                    var res = peer.PeerState == PeerStateValue.Connected;
                    peer.Disconnect();
                    return res;
                }
                Thread.Sleep(50);
            }
            return false;
        }