Exemplo n.º 1
0
        private void StartSocketClient()
        {
            // Handle any SSL Certificate issues to allow for self-signed or otherwise untrusted server certificate
            ServicePointManager.ServerCertificateValidationCallback =
                delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                         System.Security.Cryptography.X509Certificates.X509Chain chain,
                         System.Net.Security.SslPolicyErrors sslPolicyErrors)
            {
                Debug.WriteLine("------------------- !SECURE CONNECTION ALERT! ---------------------");
                Debug.WriteLine(sslPolicyErrors.ToString());
                Debug.WriteLine("");
                Debug.WriteLine(certificate.ToString());
                Debug.WriteLine("-------------------------------------------------------------------");
                return(true); // **** Always accept
            };

            if (socketClient == null)
            {
                socketClient = new CPWebSocket("wss://cpclientapi.softphone.com:9002/counterpath/socketapi/v1/");

                socketClient.Opened          += new EventHandler(OnSocketConnectionOpened);
                socketClient.Closed          += new EventHandler(OnSocketConnectionClosed);
                socketClient.Error           += new EventHandler <CPWebSocket.ErrorEventArgs>(OnSocketConnectionError);
                socketClient.MessageReceived += new EventHandler <CPWebSocket.MessageReceivedEventArgs>(OnSocketReceivedMessage);
            }

            socketClient.Open();
        }
Exemplo n.º 2
0
 private void StopSocketClient()
 {
     if (socketClient != null)
     {
         socketClient.Close();
         socketClient = null;
     }
 }