Christian Köllner cbf2144ef4 Initial commit
2019-06-12 21:56:55 +02:00

41 lines
1.1 KiB
C#

using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace Capnp.Rpc
{
abstract class RemoteCapability : RefCountingCapability
{
protected readonly IRpcEndpoint _ep;
protected RemoteCapability(IRpcEndpoint ep)
{
_ep = ep;
}
internal override IPromisedAnswer DoCall(ulong interfaceId, ushort methodId, DynamicSerializerState args, bool tailCall)
{
var call = SetupMessage(args, interfaceId, methodId);
Debug.Assert(call.Target.which != MessageTarget.WHICH.undefined);
return _ep.BeginQuestion(this, args);
}
protected virtual Call.WRITER SetupMessage(DynamicSerializerState args, ulong interfaceId, ushort methodId)
{
var callMsg = args.MsgBuilder.BuildRoot<Message.WRITER>();
callMsg.which = Message.WHICH.Call;
var call = callMsg.Call;
call.AllowThirdPartyTailCall = false;
call.InterfaceId = interfaceId;
call.MethodId = methodId;
call.Params.Content = args;
return call;
}
}
}