/// <summary>
        /// Establishes a websocket connection to the remote host.
        /// </summary>
		public void Open(Dictionary<string, string> customHeaders)
        {
            if (this.ReadyState == WebSocketState.Open)
            {
                throw new InvalidOperationException("The WebSocket is already opened.");
            }

            if (this.ReadyState == WebSocketState.Closed)
            {
                throw new InvalidOperationException("The WebSocket is closed and cannot be reused.");
            }

            if (string.IsNullOrEmpty(this.Url))
            {
                throw new InvalidOperationException("The Url parameter must be set before the WebSocket can be opened.");
            }

			this.protocol = new IETFHyBiWebSocketPotocol(this.Url, this.origin, this.protocolName, this.NoDelay);
            this.protocol.OnClose += this.OnProtocolClose;
            this.protocol.OnData += this.OnProtocolData;
            this.protocol.OnConnected += this.OnProtocolConnected;
            this.protocol.OnPing += this.OnProtocolPing;
			this.protocol.Start(customHeaders);
        }
        /// <summary>
        /// Establishes a websocket connection to the remote host.
        /// </summary>
        public void Open()
        {
            if (this.ReadyState == WebSocketState.Open)
            {
                throw new InvalidOperationException("The WebSocket is already opened.");
            }

            if (this.ReadyState == WebSocketState.Closed)
            {
                throw new InvalidOperationException("The WebSocket is closed and cannot be reused.");
            }

            if (string.IsNullOrEmpty(this.Url))
            {
                throw new InvalidOperationException("The Url parameter must be set before the WebSocket can be opened.");
            }

            this.protocol = new IETFHyBiWebSocketPotocol(this.Url, this.origin, this.protocolName, this.NoDelay);
            this.protocol.OnClose += this.OnProtocolClose;
            this.protocol.OnData += this.OnProtocolData;
            this.protocol.OnConnected += this.OnProtocolConnected;
            this.protocol.OnPing += this.OnProtocolPing;
            this.protocol.Start();
        }