43 lines
1.3 KiB
C#
Raw Permalink Normal View History

2019-06-12 21:56:55 +02:00
using System;
using System.Diagnostics;
namespace Capnp.Rpc
{
abstract class RemoteCapability : RefCountingCapability
{
protected readonly IRpcEndpoint _ep;
protected RemoteCapability(IRpcEndpoint ep)
{
_ep = ep;
}
internal IRpcEndpoint Endpoint => _ep;
internal override IPromisedAnswer DoCall(ulong interfaceId, ushort methodId, DynamicSerializerState args)
2019-06-12 21:56:55 +02:00
{
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)
{
2020-01-11 17:21:31 +01:00
if (args.MsgBuilder == null)
throw new ArgumentException("Unbound serializer state", nameof(args));
2019-06-12 21:56:55 +02:00
var callMsg = args.MsgBuilder.BuildRoot<Message.WRITER>();
callMsg.which = Message.WHICH.Call;
var call = callMsg.Call!;
2019-06-12 21:56:55 +02:00
call.AllowThirdPartyTailCall = false;
call.InterfaceId = interfaceId;
call.MethodId = methodId;
call.Params.Content = args;
return call;
}
}
2020-01-11 17:56:12 +01:00
}