Пример #1
0
        /// <summary>
        ///		Unpack error part on response message.
        /// </summary>
        /// <param name="context">Context information.</param>
        /// <returns>
        ///		<c>true</c>, if the pipeline is finished;
        ///		<c>false</c>, the pipeline is interruppted because extra data is needed.
        /// </returns>
        private bool UnpackError(ClientResponseContext context)
        {
            Contract.Assert(context.UnpackingBuffer.CanSeek);
            if (context.ErrorStartAt == -1)
            {
                context.ErrorStartAt = context.UnpackingBuffer.Position;
            }

            var skipped = context.SkipErrorSegment();

            if (skipped == null)
            {
                MsgPackRpcClientProtocolsTrace.TraceEvent(MsgPackRpcClientProtocolsTrace.NeedError, "Error value is needed. {{ \"SessionID\" : {0} }}", context.SessionId);
                return(false);
            }

            context.ErrorBuffer = new ByteArraySegmentStream(context.UnpackingBuffer.GetBuffer(context.ErrorStartAt, context.UnpackingBuffer.Position - context.ErrorStartAt));
            context.NextProcess = this.UnpackResult;

            return(context.NextProcess(context));
        }
		/// <summary>
		///		Unpack error part on response message.
		/// </summary>
		/// <param name="context">Context information.</param>
		/// <returns>
		///		<c>true</c>, if the pipeline is finished;
		///		<c>false</c>, the pipeline is interruppted because extra data is needed.
		/// </returns>
		private bool UnpackError( ClientResponseContext context )
		{
			Contract.Assert( context.UnpackingBuffer.CanSeek );
			if ( context.ErrorStartAt == -1 )
			{
				context.ErrorStartAt = context.UnpackingBuffer.Position;
			}

			var skipped = context.SkipErrorSegment();
			if ( skipped == null )
			{
				MsgPackRpcClientProtocolsTrace.TraceEvent( MsgPackRpcClientProtocolsTrace.NeedError, "Error value is needed. {{ \"SessionID\" : {0} }}", context.SessionId );
				return false;
			}

			context.ErrorBuffer = new ByteArraySegmentStream( context.UnpackingBuffer.GetBuffer( context.ErrorStartAt, context.UnpackingBuffer.Position - context.ErrorStartAt ) );
			context.NextProcess = this.UnpackResult;

			return context.NextProcess( context );
		}