コード例 #1
0
ファイル: WebSocketServer.cs プロジェクト: xdsuX/selenium
 /// <summary>
 /// Raises the StandardHttpRequestReceived event.
 /// </summary>
 /// <param name="e">A <see cref="StandardHttpRequestReceivedEventArgs"/> that contains the event data.</param>
 protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
 {
     if (this.StandardHttpRequestReceived != null)
     {
         this.StandardHttpRequestReceived(this, e);
     }
 }
コード例 #2
0
 /// <summary>
 /// Fires the StandardHttpRequestReceived event.
 /// </summary>
 /// <param name="e">A <see cref="StandardHttpRequestReceivedEventArgs"/> that contains the event data.</param>
 protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
 {
     if (this.StandardHttpRequestReceived != null)
     {
         // The event handler is to be fired, so set the Handled
         // property to true. If the user decides to let the non-handled
         // case happen, he can set the property to false in the event
         // handler.
         e.Handled = true;
         this.StandardHttpRequestReceived(this, e);
     }
 }
コード例 #3
0
        /// <summary>
        /// Fires the StandardHttpRequestReceived event.
        /// </summary>
        /// <param name="e">A <see cref="StandardHttpRequestReceivedEventArgs"/> that contains the event data.</param>
        protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e", "Event arguments cannot be null");
            }

            if (this.StandardHttpRequestReceived != null)
            {
                // The event handler is to be fired, so set the Handled
                // property to true. If the user decides to let the non-handled
                // case happen, he can set the property to false in the event
                // handler.
                e.Handled = true;
                this.StandardHttpRequestReceived(this, e);
            }
        }
コード例 #4
0
        private void CreateHandler(IEnumerable <byte> dataToParse)
        {
            var request = this.parser.Parse(dataToParse.ToArray(), this.scheme);

            if (request == null)
            {
                return;
            }

            try
            {
                this.Handler = HandlerFactory.BuildHandler(request);
            }
            catch (WebSocketException)
            {
                StandardHttpRequestReceivedEventArgs e = new StandardHttpRequestReceivedEventArgs(this);
                this.OnStandardHttpRequestReceived(e);
                if (!e.Handled)
                {
                    throw;
                }
            }

            if (this.Handler == null)
            {
                return;
            }

            this.Handler.TextMessageHandled   += new EventHandler <TextMessageHandledEventArgs>(this.Handler_TextMessageHandled);
            this.Handler.BinaryMessageHandled += new EventHandler <BinaryMessageHandledEventArgs>(this.Handler_BinaryMessageHandled);
            this.Handler.CloseHandled         += new EventHandler(this.Handler_CloseHandled);
            this.ConnectionInfo = WebSocketConnectionInfo.Create(request, this.Socket.RemoteIPAddress);

            var handshake = this.Handler.CreateHandshake();

            this.SendBytes(handshake);
            this.OnOpen(new ConnectionEventArgs(this));
        }
コード例 #5
0
ファイル: WebSocketServer.cs プロジェクト: xdsuX/selenium
 private void ConnectionStandardHttpRequestReceivedEventHandler(object sender, StandardHttpRequestReceivedEventArgs e)
 {
     this.OnStandardHttpRequestReceived(e);
 }
コード例 #6
0
        private void ServerStandardHttpRequestReceivedEventHandler(object sender, StandardHttpRequestReceivedEventArgs e)
        {
            const string PageSource = @"<!DOCTYPE html>
  <script>
    window.onload = function() {{
      window.postMessage({{
        'type': 'connect',
        'origin': 'webdriver',
        'url': 'ws://localhost:{0}/wd'
        }}, '*');
    }};
  </script>";

            string redirectPage = string.Format(CultureInfo.InvariantCulture, PageSource, this.webSocketServer.Port.ToString(CultureInfo.InvariantCulture));
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("HTTP/1.1 200");
            builder.AppendLine("Content-Length: " + redirectPage.Length.ToString(CultureInfo.InvariantCulture));
            builder.AppendLine("Connection:close");
            builder.AppendLine();
            builder.AppendLine(redirectPage);
            e.Connection.SendRaw(builder.ToString());
        }
コード例 #7
0
        private void CreateHandler(IEnumerable<byte> dataToParse)
        {
            var request = this.parser.Parse(dataToParse.ToArray(), this.scheme);
            if (request == null)
            {
                return;
            }

            try
            {
                this.Handler = HandlerFactory.BuildHandler(request);
            }
            catch (WebSocketException)
            {
                StandardHttpRequestReceivedEventArgs e = new StandardHttpRequestReceivedEventArgs(this);
                this.OnStandardHttpRequestReceived(e);
                if (!e.Handled)
                {
                    throw;
                }
            }

            if (this.Handler == null)
            {
                return;
            }

            this.Handler.TextMessageHandled += new EventHandler<TextMessageHandledEventArgs>(this.Handler_TextMessageHandled);
            this.Handler.BinaryMessageHandled += new EventHandler<BinaryMessageHandledEventArgs>(this.Handler_BinaryMessageHandled);
            this.Handler.CloseHandled += new EventHandler(this.Handler_CloseHandled);
            this.ConnectionInfo = WebSocketConnectionInfo.Create(request, this.Socket.RemoteIPAddress);

            var handshake = this.Handler.CreateHandshake();
            this.SendBytes(handshake);
            this.OnOpen(new ConnectionEventArgs(this));
        }
コード例 #8
0
        /// <summary>
        /// Fires the StandardHttpRequestReceived event.
        /// </summary>
        /// <param name="e">A <see cref="StandardHttpRequestReceivedEventArgs"/> that contains the event data.</param>
        protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e", "Event arguments cannot be null");
            }

            if (this.StandardHttpRequestReceived != null)
            {
                // The event handler is to be fired, so set the Handled
                // property to true. If the user decides to let the non-handled
                // case happen, he can set the property to false in the event
                // handler.
                e.Handled = true;
                this.StandardHttpRequestReceived(this, e);
            }
        }
コード例 #9
0
 private void ConnectionStandardHttpRequestReceivedEventHandler(object sender, StandardHttpRequestReceivedEventArgs e)
 {
     this.OnStandardHttpRequestReceived(e);
 }
コード例 #10
0
 /// <summary>
 /// Raises the StandardHttpRequestReceived event.
 /// </summary>
 /// <param name="e">A <see cref="StandardHttpRequestReceivedEventArgs"/> that contains the event data.</param>
 protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
 {
     if (this.StandardHttpRequestReceived != null)
     {
         this.StandardHttpRequestReceived(this, e);
     }
 }
コード例 #11
0
ファイル: WebSocketConnection.cs プロジェクト: Zekom/selenium
 /// <summary>
 /// Fires the StandardHttpRequestReceived event.
 /// </summary>
 /// <param name="e">A <see cref="StandardHttpRequestReceivedEventArgs"/> that contains the event data.</param>
 protected void OnStandardHttpRequestReceived(StandardHttpRequestReceivedEventArgs e)
 {
     if (this.StandardHttpRequestReceived != null)
     {
         // The event handler is to be fired, so set the Handled
         // property to true. If the user decides to let the non-handled
         // case happen, he can set the property to false in the event
         // handler.
         e.Handled = true;
         this.StandardHttpRequestReceived(this, e);
     }
 }