/// <summary> /// Constructs a new WebSocket that will connect to the provided URI and read messages in the provided format. /// Can be cancelled through the provided <see cref="CancellationToken"/> /// </summary> /// <param name="address"></param> /// <param name="msgType"></param> /// <param name="tokenSource"></param> public WebSocket(Uri address, WebSocketMessageEncoding msgType, System.Net.IWebProxy proxy) { _ws = new ClientWebSocket(); (_ws as ClientWebSocket).Options.Proxy = proxy; _msgType = (WebSocketMessageType)msgType; _uri = address; _rQ = new ConcurrentQueue <IEnumerable <byte> >(); _sQ = new ConcurrentQueue <IEnumerable <byte> >(); //Maximum 2 requests can be made at once, see above _sem = new SemaphoreSlim(2, 2); }
/// <summary> /// Constructs a new WebSocket that will connect to the provided internet address and read messages in the provided format. /// Can be cancelled through the provided <see cref="CancellationToken"/> /// </summary> /// <param name="address"></param> /// <param name="msgType"></param> /// <param name="tokenSource"></param> public WebSocket(string address, WebSocketMessageEncoding msgType, System.Net.IWebProxy proxy) : this(new Uri(address), msgType, proxy) { }