Ejemplo n.º 1
0
 private void responseReceivedHandler(object sender, DataEventArgs e)
 {
     if (e.Data == null)
     {
         return;
     }
     lock (parser)
     {
         IDataStream data = null;
         try
         {
             data = parser.Receive(e.Data);
         }
         catch
         {
             data   = parser.GetRawData();
             parser = new HttpMessageParser(logger, true);
         }
         if (data != null)
         {
             OnResponseReceived(data);
             parser = new HttpMessageParser(logger, true);
         }
     }
 }
Ejemplo n.º 2
0
 private void channelClosedHandler(object sender)
 {
     lock (parser)
     {
         var data = parser.Close();
         if (data != null)
         {
             OnResponseReceived(data);
             parser = new HttpMessageParser(logger, true);
         }
     }
     OnChannelClosed();
 }
Ejemplo n.º 3
0
 public HttpServerChannel(IServerChannel channel, InstanceLogger logger)
 {
     if (channel.GetType() != typeof(LockableServerChannel))
     {
         channel = new LockableServerChannel(channel);
     }
     this.channel = (LockableServerChannel)channel;
     this.id      = channel.ID;
     this.name    = channel.Name;
     handlers     = new IChannelExtensions.ChannelHandlers
     {
         ChannelClosed   = channelClosedHandler,
         ChannelReady    = channelReadyHandler,
         RequestReceived = requestReceivedHandler,
         ResponseSent    = responseSentHandler,
         ErrorOccured    = errorOccuredHandler,
     };
     channel.BindAllEvents(handlers);
     parser      = new HttpMessageParser(logger, false);
     this.logger = logger;
 }
Ejemplo n.º 4
0
        public HttpClientChannel(IClientChannel channel, InstanceLogger logger, HttpServerChannel serverChannel = null)
        {
            var sharedLockChannel = serverChannel != null?serverChannel.GetInnerChannel() : null;

            if (channel.GetType() != typeof(LockableClientChannel))
            {
                channel = new LockableClientChannel(channel, sharedLockChannel);
            }
            this.channel = (LockableClientChannel)channel;
            this.id      = channel.ID;
            this.name    = channel.Name;
            handlers     = new IChannelExtensions.ChannelHandlers
            {
                ChannelClosed    = channelClosedHandler,
                ChannelReady     = channelReadyHandler,
                ResponseReceived = responseReceivedHandler,
                RequestSent      = requestSentHandler,
                ErrorOccured     = errorOccuredHandler,
            };
            channel.BindAllEvents(handlers);
            parser      = new HttpMessageParser(logger, true);
            this.logger = logger;
        }