public async Task ConnectAsync(Uri uri, WebSocketConnectionOptions options)
{
if (_ws != null)
{
_ws.Dispose();
}
//ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
//{
// //// local dev, just approve all certs
// //if (development) return true;
// //return errors == SslPolicyErrors.None;
// return true;
//};
_ws = CreateClient();
//var cert = new X509Certificate2(@"C:\Users\41608\Downloads\cert\client1-crt.pem");
//var privateKey = cert.PrivateKey as RSACryptoServiceProvider;
//privateKey.en
//_ws.Options.ClientCertificates.Add(cert);
_connectionToken = new CancellationTokenSource();
await _ws.ConnectAsync(uri, _connectionToken.Token);
await Task.Factory.StartNew(ListenAsync, _connectionToken.Token);
await Task.Factory.StartNew(ListenStateAsync, _connectionToken.Token);
}