/// <summary> /// The event handle for the received http request. /// </summary> /// <param name="context">The http listener context.</param> private void RaiseIncomingRequest(HttpListenerContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (this.logger != null) { this.logger.AddDebug(string.Format( "Http request is received, the remote endpoint's ip address is {0}, the port is {1}", context.Request.RemoteEndPoint.Address, context.Request.RemoteEndPoint.Port)); } HttpRequestEventArg newHttpReqeust = new HttpRequestEventArg(context); try { if (this.httpRequestEventHandle != null) { this.httpRequestEventHandle.BeginInvoke(this, newHttpReqeust, null, null); } } catch (InvalidOperationException e) { if (this.logger != null) { this.logger.AddWarning( string.Format("Unexpected exception detailed information: {0}.", e.Message)); } } }
/// <summary> /// THe handle for the received http request event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">THe http request event.</param> private void ReceiveHttpRequest(object sender, HttpRequestEventArg e) { lock (this.locker) { HttpListenerRequest request = e.ListenerContext.Request; this.DecomposeHttpRequest(request); PCHC_MESSAGE_TYPE msgType = DecodeMessage.GetMessageType(this.httpRequestPayload); if (msgType == PCHC_MESSAGE_TYPE.INITIAL_OFFER_MESSAGE) { lock (this.initialQueue) { this.initialQueue.Enqueue(e.ListenerContext); } } else if (msgType == PCHC_MESSAGE_TYPE.SEGMENT_INFO_MESSAGE) { lock (this.segmentQueue) { this.segmentQueue.Enqueue(e.ListenerContext); } } } }
/// <summary> /// The handle to HTTP request message. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The MessageReceivedEvent args.</param> private void OnHttpRequestMessageReceived(object sender, HttpRequestEventArg e) { lock (this) { this.pccrtpRequest.HttpRequest = e.ListenerContext.Request; this.httpListenerContext = e.ListenerContext; } }
/// <summary> /// Receive pccrr message. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e argu.</param> private void HttpServerTransport_ReceiveFrom(object sender, HttpRequestEventArg e) { lock (this) { this.httpListenerContext = e.ListenerContext; this.MessageArrived( e.ListenerContext.Request.RemoteEndPoint, this.DecodePacket( e.ListenerContext.Request.Url, (HttpMethod)Enum.Parse( typeof(HttpMethod), e.ListenerContext.Request.HttpMethod), this.DecomposeHttpRequest( e.ListenerContext.Request))); } }