/// <summary> /// Initiates an asynchronous call to the HTTP handler. /// </summary> /// <param name="context">An HttpContext object that provides references to intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param> /// <param name="cb">The AsyncCallback to call when the asynchronous method call is complete. If cb is a null reference (Nothing in Visual Basic), the delegate is not called.</param> /// <param name="extraData">Any extra data needed to process the request.</param> /// <returns>An IAsyncResult that contains information about the status of the process.</returns> public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { try { HttpServerRequestResult httpServerRequestResult = new HttpServerRequestResult(context, cb, extraData); httpServerRequestResult.IPrincipal = Thread.CurrentPrincipal; lock (this._httpServerConnectionManagerLock) if (this._httpServerConnectionManager == null) { GenuineHttpServerChannel serverChannel = ChannelServices.GetChannel("ghttp") as GenuineHttpServerChannel; if (serverChannel == null) throw GenuineExceptions.Get_Receive_NoServerChannel(); this._httpServerConnectionManager = serverChannel.ITransportContext.ConnectionManager as HttpServerConnectionManager; } // GenuineThreadPool.QueueUserWorkItem(new WaitCallback(this._httpServerConnectionManager.HandleIncomingRequest), httpServerRequestResult, true); this._httpServerConnectionManager.HandleIncomingRequest(httpServerRequestResult); return httpServerRequestResult; } catch(Exception ex) { // LOG: BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter; if ( binaryLogWriter != null && binaryLogWriter[LogCategory.AcceptingConnection] > 0 ) { binaryLogWriter.WriteEvent(LogCategory.AcceptingConnection, "HttpServerHandler.BeginProcessRequest", LogMessageType.ConnectionAccepting, ex, null, null, null, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, null, null, -1, 0, 0, 0, null, null, null, null, "Can't process an incoming connection."); } throw; } }
/// <summary> /// Constructs an instance of the HttpServerConnection class. /// </summary> /// <param name="iTransportContext">The Transport Context.</param> /// <param name="hostId">The id of the remote host.</param> /// <param name="remote">The remote host.</param> /// <param name="connectionName">The name of the connection.</param> /// <param name="closeConnectionAfterInactivity">The time span to renew a connection after each message.</param> public HttpServerConnection(ITransportContext iTransportContext, Guid hostId, HostInformation remote, string connectionName, int closeConnectionAfterInactivity) { this.ITransportContext = iTransportContext; this.HttpServerConnectionManager = (HttpServerConnectionManager) iTransportContext.ConnectionManager; this.ConnectionName = connectionName; this.CloseConnectionAfterInactivity = closeConnectionAfterInactivity; this.HostId = hostId.ToByteArray(); this.HostIdAsString = hostId.ToString("N"); this.Listener_MessageContainer = new MessageContainer(iTransportContext); this.Remote = remote; }