/// <summary> /// Initializes a new instance of the <see cref="WebSocket" /> class with /// the specified WebSocket URL. /// </summary> /// <param name="url">A <see cref="string" /> that represents the WebSocket URL to connect.</param> /// <exception cref="System.ArgumentNullException">url.</exception> /// <exception cref="System.ArgumentException"> /// An empty string. - url /// or /// url /// or /// protocols. /// </exception> /// <exception cref="ArgumentNullException"><paramref name="url" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentException"><para> /// <paramref name="url" /> is invalid. /// </para> /// <para> /// -or- /// </para></exception> public WebSocket(string url) { if (url == null) { throw new ArgumentNullException(nameof(url)); } if (url.Length == 0) { throw new ArgumentException("An empty string.", nameof(url)); } if (!url.TryCreateWebSocketUri(out _uri, out var msg)) { throw new ArgumentException(msg, nameof(url)); } _base64Key = CreateBase64Key(); IsClient = true; _message = Messagec; #if SSL IsSecure = _uri.Scheme == "wss"; #endif _waitTime = TimeSpan.FromSeconds(5); _forMessageEventQueue = ((ICollection)_messageEventQueue).SyncRoot; _validator = new WebSocketValidator(this); }
// As server internal WebSocket(WebSocketContext context) { _context = context; WebSocketKey = new WebSocketKey(); IsSecure = context.IsSecureConnection; _stream = context.Stream; _waitTime = TimeSpan.FromSeconds(1); _validator = new WebSocketValidator(this); }
// As server internal WebSocket(WebSocketContext context) { _context = context; _message = Messages; #if SSL IsSecure = context.IsSecureConnection; #endif _stream = context.Stream; _waitTime = TimeSpan.FromSeconds(1); _forMessageEventQueue = ((ICollection)_messageEventQueue).SyncRoot; _validator = new WebSocketValidator(this); }
// As server internal WebSocket(WebSocketContext context) { _context = context; _message = Messages; WebSocketKey = new WebSocketKey(false); #if SSL IsSecure = context.IsSecureConnection; #endif _stream = context.Stream; _waitTime = TimeSpan.FromSeconds(1); _validator = new WebSocketValidator(this); }
/// <summary> /// Initializes a new instance of the <see cref="WebSocket" /> class with /// the specified WebSocket URL. /// </summary> /// <param name="url">A <see cref="string" /> that represents the WebSocket URL to connect.</param> /// <exception cref="System.ArgumentNullException">url.</exception> /// <exception cref="System.ArgumentException"> /// An empty string. - url /// or /// url /// or /// protocols. /// </exception> /// <exception cref="ArgumentNullException"><paramref name="url" /> is <see langword="null" />.</exception> /// <exception cref="ArgumentException"><para> /// <paramref name="url" /> is invalid. /// </para> /// <para> /// -or- /// </para></exception> public WebSocket(string url) { _uri = url.CreateWebSocketUri(); WebSocketKey = new WebSocketKey(true); IsClient = true; _message = Messagec; #if SSL IsSecure = _uri.Scheme == "wss"; #endif _waitTime = TimeSpan.FromSeconds(5); _validator = new WebSocketValidator(this); }