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); }
protected override void SendCore(ServerResponseContext context) { this._manager.SendAsync(context) .ContinueWith( previous => this.OnSent(context) ).Wait(this._receivingCancellationTokenSource.Token); }
/// <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); } }
/// <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 )); }
protected override void SendCore(ServerResponseContext context) { Contract.Requires(context != null); }
internal SentEventArgs(ServerResponseContext context) { this._context = context; }
public static byte[] GetReturnValueData(this ServerResponseContext source) { return(source.SendingBuffer[3].AsEnumerable().ToArray()); }
public static byte[] GetMessageId(this ServerResponseContext source) { return(source.SendingBuffer[1].AsEnumerable().ToArray()); }
public static byte[] GetTypeHeader(this ServerResponseContext source) { return(source.SendingBuffer[0].AsEnumerable().ToArray()); }