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; } }
public async Task ConnectAsyncCore(Uri uri, CancellationToken cancellationToken, ClientWebSocketOptions options) { try { await _webSocket.ConnectAsync(uri, cancellationToken, options).ConfigureAwait(false); } 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 (NetEventSource.IsEnabled) { NetEventSource.Error(_webSocket, wex); } throw wex; } }
public async Task ConnectAsyncCore(Uri uri, CancellationToken cancellationToken, ClientWebSocketOptions options) { try { await _webSocket.ConnectAsync(uri, cancellationToken, options).ConfigureAwait(false); } catch (Exception ex) { // TODO #4143: ** TFS BUILD IS BROKEN ** // This doesn't compile right now due to missing types 'WebErrorStatus' and 'RTWebSocketError' // Commenting out for now to allow the build to resume. //WebErrorStatus status = RTWebSocketError.GetStatus(ex.HResult); //var inner = new Exception(status.ToString(), ex); var inner = ex; WebSocketException wex = new WebSocketException(SR.net_webstatus_ConnectFailure, inner); if (Logging.On) { Logging.Exception(Logging.WebSockets, this, "ConnectAsync", wex); } throw wex; } }
public async Task ConnectAsyncCore(Uri uri, CancellationToken cancellationToken, ClientWebSocketOptions options) { if (options.RemoteCertificateValidationCallback != null) { throw new PlatformNotSupportedException(SR.net_WebSockets_RemoteValidationCallbackNotSupported); } try { await _webSocket.ConnectAsync(uri, cancellationToken, options).ConfigureAwait(false); } catch (Exception ex) { WebErrorStatus status = RTWebSocketError.GetStatus(ex.HResult); var inner = new Exception(status.ToString(), ex); WebSocketException wex = new WebSocketException(WebSocketError.Faulted, SR.net_webstatus_ConnectFailure, inner); if (NetEventSource.IsEnabled) { NetEventSource.Error(_webSocket, wex); } throw wex; } }