Exemple #1
0
        private async Task ConnectAsyncCore(Uri uri, CancellationToken cancellationToken)
        {
            var rtWebSocket = new WinRTWebSocket();

            _innerWebSocket = rtWebSocket;

            try
            {
                // Change internal state to 'connected' to enable the other methods
                if ((InternalState)Interlocked.CompareExchange(ref _state, (int)InternalState.Connected, (int)InternalState.Connecting) != InternalState.Connecting)
                {
                    // Aborted/Disposed during connect.
                    throw new ObjectDisposedException(GetType().FullName);
                }

                await rtWebSocket.ConnectAsync(uri, cancellationToken, Options);
            }
            catch (Exception ex)
            {
                WebErrorStatus     status = RTWebSocketError.GetStatus(ex.HResult);
                var                inner  = new Exception(status.ToString(), ex);
                WebSocketException wex    = new WebSocketException(SR.net_webstatus_ConnectFailure, inner);
                if (Logging.On)
                {
                    Logging.Exception(Logging.WebSockets, this, "ConnectAsync", wex);
                }

                throw wex;
            }
        }
Exemple #2
0
 private WebSocketHandle(WinRTWebSocket webSocket)
 {
     _webSocket = webSocket;
 }
 private WebSocketHandle(WinRTWebSocket webSocket)
 {
     _webSocket = webSocket;
 }