/// <summary> /// Processes the listening request on the server side. /// </summary> /// <param name="xHttpConnection">The connection.</param> /// <param name="xHttpPhysicalConnection">The physical connection.</param> private void Pool_Server_ProcessListenerRequest(XHttpConnection xHttpConnection, XHttpPhysicalConnection xHttpPhysicalConnection) { lock (xHttpConnection.Listener.PhysicalConnectionStateLock) { try { Message message = xHttpConnection.MessageContainer.GetMessage(); if (message == null) { // no data is available, postpone the request // xHttpPhysicalConnection.Listener_Opened = GenuineUtility.TickCount; xHttpPhysicalConnection.MarkAsAvailable(); return; } // some data is available, gather the stream and send it this.LowLevel_SendHttpContent(GenuineUtility.GetTimeout(xHttpConnection.CloseConnectionAfterInactivity), message, null, null, xHttpConnection.MessageContainer, xHttpPhysicalConnection, xHttpConnection.GenuineConnectionType, HttpPacketType.Usual, false, true, true, true); } catch(Exception ex) { // LOG: BinaryLogWriter binaryLogWriter = this.ITransportContext.BinaryLogWriter; if ( binaryLogWriter != null && binaryLogWriter[LogCategory.Connection] > 0 ) { binaryLogWriter.WriteEvent(LogCategory.Connection, "XHttpConnectionManager.Pool_Server_ProcessListenerRequest", LogMessageType.AsynchronousSendingStarted, ex, null, xHttpPhysicalConnection.Remote, null, GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, null, null, xHttpConnection.DbgConnectionId, 0, 0, 0, null, null, null, null, "Error occurred while sending HTTP Listener Request. Sequence No: {0}.", xHttpPhysicalConnection.SequenceNo); } } } }
/// <summary> /// Starts sending a message if one is available. Marks the connection is available if there are no messages at the moment. /// Does not process exceptions. /// </summary> /// <param name="xHttpPhysicalConnection">The sending connection.</param> private void Pool_Sender_HandleClientConnection(XHttpPhysicalConnection xHttpPhysicalConnection) { lock (xHttpPhysicalConnection.PhysicalConnectionStateLock) { Message message = xHttpPhysicalConnection.XHttpConnection.MessageContainer.GetMessage(); if (message == null) { xHttpPhysicalConnection.MarkAsAvailable(); return ; } this.LowLevel_SendHttpContent(GenuineUtility.GetTimeout(xHttpPhysicalConnection.XHttpConnection.CloseConnectionAfterInactivity), message, null, null, xHttpPhysicalConnection.XHttpConnection.MessageContainer, xHttpPhysicalConnection, GenuineConnectionType.Persistent, HttpPacketType.Usual, false, true, true, true); } }