示例#1
0
        // 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);
        }
示例#2
0
        // 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);
        }
示例#3
0
        /// <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);
        }