/// <summary>
        /// Connect the websocket to Coinbase Pro.
        /// </summary>
        /// <returns></returns>
        public Task <ConnectResult> ConnectAsync()
        {
            if (this.RawSocket != null)
            {
                throw new InvalidOperationException(
                          $"The {nameof(RawSocket)} is already created from a previous {nameof(ConnectAsync)} call. " +
                          $"If you get this exception, you'll need to dispose of this {nameof(CoinbaseProWebSocket)} and create a new instance. " +
                          $"Don't call {nameof(ConnectAsync)} multiple times on the same instance.");
            }

            this.connectingTcs = new TaskCompletionSource <ConnectResult>();

            if (this.RawSocket is null)
            {
                this.RawSocket ??= new WebSocket(this.Config.SocketUri);
                this.RawSocket.Proxy = this.Proxy;
                this.RawSocket.Security.EnabledSslProtocols = SslProtocols.Tls12;
            }

            this.RawSocket.Opened += RawSocket_Opened;
            this.RawSocket.Error  += RawSocket_Error;
            this.RawSocket.Open();

            return(this.connectingTcs.Task);
        }
예제 #2
0
 /// <summary>
 /// Creates a new instance of the <b>ConnectionBase</b> class.
 /// </summary>
 /// <param name="server">The URI of the server to connect to.</param>
 /// <param name="port">The port of the server to connect to.</param>
 public ThinProxiedConnectionBase(string server, int port)
     : base(server, port)
 {
     m_proxy = new NoProxyProxyConnector();
     m_proxy.Initialize(this);
 }
 /// <summary>
 /// Creates a new instance of the <b>ConnectionBase</b> class.
 /// </summary>
 /// <param name="server">The URI of the server to connect to.</param>
 /// <param name="port">The port of the server to connect to.</param>
 public ThinProxiedConnectionBase(string server, int port)
     : base(server, port)
 {
     m_proxy = new NoProxyProxyConnector();
     m_proxy.Initialize(this);
 }
 public void EnableFiddlerDebugProxy(IProxyConnector proxy)
 {
     this.Proxy = proxy;
 }
 public Connection(Pusher pusher, string url, IProxyConnector proxy = null)
 {
     this._url = url;
     this._pusher = pusher;
     this._proxy = proxy;
 }