private void HandleParserPartialDataAvailable( object sender, HttpDataEventArgs e ) { try { ServiceLog.Logger.Verbose( "{0} ClientSession -- waiting to send partial data to server", Id ); _connectToServerEvent.WaitOne(); ServiceLog.Logger.Verbose( "{0} ClientSession -- sending partial data to server", Id ); _dispatcher.SendServerData( e.Data, HandleServerSend ); } catch ( Exception ex ) { ServiceLog.Logger.Exception( string.Format( "{0} Unhandled exception sending data to server.", Id ), ex ); Reset(); } }
private void _dispatcher_PartialDataAvailable( object sender, HttpDataEventArgs e ) { ServiceLog.Logger.Verbose( "{0} ClientSession -- partial data available from server -- send to client", Id ); if ( _clientConnection != null ) { //_sendingDataToClientLock.Reset(); _clientConnection.BeginSend( e.Data, HandleSendToClient ); } }
private void ParserBodyAvailable( object sender, HttpDataEventArgs e ) { byte[] filterResponse = _responseFilter.ApplyResponseBodyFilter( _lastResponse, e.Data, _callbacks ); if ( filterResponse == null ) { throw new InvalidOperationException( "Response body filter did not return a response for the client" ); } // Unsubscribe to the parser events. If we don't, the Close invocation will recursively // invoke this method and we get a stack overflow. _parser.BodyAvailable -= ParserBodyAvailable; OnDataAvailable( filterResponse ); Close(); }
private void ParserPartialDataAvailable( object sender, HttpDataEventArgs e ) { OnDataAvailable( e.Data ); }
private void HandleServerParserPartialDataAvailable( object sender, HttpDataEventArgs e ) { Contract.Requires( e != null ); ServiceLog.Logger.Verbose( "{0} SessionContext::HandleServerParserPartialDataAvailable", Id ); try { lock ( _changeClientConnectionMutex ) { if ( State.ShouldSendPartialDataToClient( e.Data, this ) && ClientConnection != null ) { SendClientData( e.Data ); } else { ServiceLog.Logger.Info( "{0} Skipping sending client data. CLIENT NULL: {1}", Id, ( ClientConnection == null ) ); } } } catch ( Exception ex ) { ServiceLog.Logger.Exception( string.Format( "{0} Unhandled exception when processing partial data from server", Id ), ex ); ChangeState( SessionStateType.Error ); } }
private void HandleServerParserBodyAvailable( object sender, HttpDataEventArgs e ) { Contract.Requires( e != null ); Contract.Requires( _bodyAvailableCallback != null ); Contract.Ensures( _bodyAvailableCallback == null ); ServiceLog.Logger.Verbose( "{0} SessionContext::HandleServerParserBodyAvailable", Id ); //lock (_mutex) { try { ServerParser.BodyAvailable -= HandleServerParserBodyAvailable; _bodyAvailableCallback( e.Data, this ); _bodyAvailableCallback = null; } catch ( Exception ex ) { ServiceLog.Logger.Exception( string.Format( "{0} Unhandled exception when evaluating response body", Id ), ex ); ChangeState( SessionStateType.Error ); } } }
private void ParserPartialDataAvailable( object sender, HttpDataEventArgs e ) { _logger.Verbose("Partial data available from client"); try { // Wait for the server connection before sending data _logger.Verbose( "Sending data to remote host" ); _serverConnectingEvent.WaitOne(); if( !_serverDispatcher.TrySendDataToActiveServer( e.Data ) ) { _logger.Info("Unable to send data to active server. No servers may remain."); Reset(); } } catch ( Exception ex ) { _logger.Exception( "Unhandled exception sending partial data to server", ex ); Reset(); } finally { _serverConnectingEvent.Release(); } }