예제 #1
0
        public static byte[] SetReturnValueData(this ServerResponseContext source, byte[] value)
        {
            var old = source.SendingBuffer[3].AsEnumerable().ToArray();

            source.SendingBuffer[3] = new ArraySegment <byte>(value);
            return(old);
        }
예제 #2
0
 protected override void SendCore(ServerResponseContext context)
 {
     this._manager.SendAsync(context)
     .ContinueWith(
         previous => this.OnSent(context)
         ).Wait(this._receivingCancellationTokenSource.Token);
 }
예제 #3
0
 /// <summary>
 ///		Performs protocol specific asynchronous 'Send' operation.
 /// </summary>
 /// <param name="context">Context information.</param>
 protected sealed override void SendCore(ServerResponseContext context)
 {
     // Manager stores the socket which is dedicated socket to this transport in the AcceptSocket property.
     if (!this.BoundSocket.SendToAsync(context.SocketContext))
     {
         context.SetCompletedSynchronously();
         this.OnSent(context);
     }
 }
예제 #4
0
        /// <summary>
        ///		Performs protocol specific asynchronous 'Send' operation.
        /// </summary>
        /// <param name="context">Context information.</param>
        protected sealed override void SendCore(ServerResponseContext context)
        {
            Contract.Assert(this.BoundSocket != null);

            if (!this.BoundSocket.SendAsync(context.SocketContext))
            {
                context.SetCompletedSynchronously();
                this.OnSent(context);
            }
        }
        /// <summary>
        /// Performs protocol specific asynchronous 'Send' operation.
        /// </summary>
        /// <param name="context">Context information.</param>
        protected override void SendCore(ServerResponseContext context)
        {
            var handler = this.Sent;

            if (handler != null)
            {
                handler(this, new SentEventArgs(context));
            }

            return;
        }
 private static void TestCore(Action <ServerResponseContext, ServerTransport> test)
 {
     using (var server = new RpcServer())
         using (var manager = new NullServerTransportManager(server))
             using (var transport = new NullServerTransport(manager))
                 using (var target = new ServerResponseContext())
                 {
                     target.SetTransport(transport);
                     test(target, transport);
                 }
 }
        /// <summary>
        ///		Returns the response context to the pool.
        /// </summary>
        /// <param name="context">The response to the pool.</param>
        /// <exception cref="ArgumentNullException">
        ///		<paramref name="context"/> is  <c>null</c>.
        /// </exception>
        protected internal void ReturnResponseContext(ServerResponseContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            Contract.EndContractBlock();

            context.Clear();
            context.UnboundTransport();
            this.ResponseContextPool.Return(context);
        }
        /// <summary>
        ///		Process in-proc communication sending response.
        /// </summary>
        /// <param name="context">The <see cref="ServerResponseContext"/>.</param>
        /// <returns>
        ///		<see cref="Task"/> to be notified async operation result.
        /// </returns>
        internal Task SendAsync(ServerResponseContext context)
        {
            Contract.Assert(context != null);
            Contract.Assert(context.SocketContext.BufferList != null);

            var data = context.SocketContext.BufferList.SelectMany(b => b.Array.Skip(b.Offset).Take(b.Count)).ToArray();

            context.SetBytesTransferred(data.Length);

            return
                (Task.Factory.StartNew(
                     state => this.SendResponseData(state as byte[]),
                     data
                     ));
        }
예제 #9
0
 protected override void SendCore(ServerResponseContext context)
 {
     Contract.Requires(context != null);
 }
 internal SentEventArgs(ServerResponseContext context)
 {
     this._context = context;
 }
예제 #11
0
 public static byte[] GetReturnValueData(this ServerResponseContext source)
 {
     return(source.SendingBuffer[3].AsEnumerable().ToArray());
 }
예제 #12
0
 public static byte[] GetMessageId(this ServerResponseContext source)
 {
     return(source.SendingBuffer[1].AsEnumerable().ToArray());
 }
예제 #13
0
 public static byte[] GetTypeHeader(this ServerResponseContext source)
 {
     return(source.SendingBuffer[0].AsEnumerable().ToArray());
 }