コード例 #1
0
 protected override void OnReceiveCore( ReceivingContext context, ResponseMessage response, RpcErrorMessage error )
 {
     base.OnReceiveCore( context, response, error );
     this._connectionPool.Return( context.SocketContext );
     context.SessionContext.Dispose();
     // FIXME: Return to buffer pool.
 }
コード例 #2
0
 protected virtual ChunkBuffer ReallocateReceivingBufferCore( ChunkBuffer oldBuffer, long requestedLength, ReceivingContext context )
 {
     return ChunkBuffer.CreateDefault( context.SessionContext.Options.BufferSegmentCount ?? 1, context.SessionContext.Options.BufferSegmentSize ?? ChunkBuffer.DefaultSegmentSize );
 }
コード例 #3
0
        protected virtual void OnReceiveCore( ReceivingContext context, ResponseMessage response, RpcErrorMessage error )
        {
            IResponseHandler handler;
            bool removed;
            try { }
            finally
            {
                removed = this._sessionTable.TryRemove( response.MessageId, out handler );
                this._sessionTableLatch.Signal();
            }

            if ( removed )
            {
                if ( error.IsSuccess )
                {
                    handler.HandleResponse( response, false );
                }
                else
                {
                    handler.HandleError( error, false );
                }
            }
            else
            {
                // TODO: trace unrecognized receive message.
            }
        }
コード例 #4
0
 ChunkBuffer ITransportReceiveHandler.ReallocateReceivingBuffer( ChunkBuffer oldBuffer, long requestedLength, ReceivingContext context )
 {
     return this.ReallocateReceivingBufferCore( oldBuffer, requestedLength, context );
 }
コード例 #5
0
 void ITransportReceiveHandler.OnReceive( ReceivingContext context )
 {
     ResponseMessage result;
     // FIXME: Feeding deserliaztion.
     //	If data is not enough, Deserialize return null.
     //  So this method return false, caller(EventLoop) retrieve more data.
     //  Feeding callback is NOT straight forward.
     var error = this._responseSerializer.Deserialize( context.ReceivingBuffer, out result );
     this.OnReceiveCore( context, result, error );
 }
コード例 #6
0
 protected override sealed void ReceiveFromCore( ReceivingContext context )
 {
     if ( !context.SocketContext.ReceiveFromAsync() )
     {
         context.SocketContext.OnReceived( true );
     }
 }
コード例 #7
0
 protected override sealed void OnReceived( ReceivingContext context, bool completedSynchronously )
 {
     if ( context.SessionContext.IsInContinuousRetrieval )
     {
         // Eventually continue blocked unpacking process.
         context.SessionContext.RetrievalWaitHandle.Set();
         return;
     }
     else
     {
         // Eventually invoke callback from ITransportReceiveHandler
         base.OnReceived( context, completedSynchronously );
     }
 }
コード例 #8
0
 public ChunkBuffer ReallocateReceivingBuffer( ChunkBuffer oldBuffer, long requestedLength, ReceivingContext context )
 {
     return ChunkBuffer.CreateDefault();
 }
コード例 #9
0
            public void OnReceive( ReceivingContext context )
            {
                context.SocketContext.UserToken = context;

                var handler = this.Received;
                if ( handler != null )
                {
                    handler( context );
                }
            }