public void InvocationStartRequestSerialization() { var serializer = SerializerFactory.Create(MessageFactory); using (var request = MessageFactory.CreateInvocationStartRequest("interop.testing.EchoService", "Unary")) using (var serialized = serializer.Serialize(request)) using (var deserialized = serializer.DeserializeClientToBrokerRequest(serialized)) { deserialized.Handle(new ClientToBrokerRequestHandler <Nothing, Nothing>( (msg, _) => { return(msg.Target.Handle(new InvocationTargetHandler <Nothing, Nothing>( (target, __) => { target.MethodId.ShouldBe("Unary"); target.ConsumedService.ServiceId.ShouldBe("interop.testing.EchoService"); target.ConsumedService.ServiceAlias.ShouldBe(Maybe <string> .Nothing); return Nothing.Instance; }, (target, __) => throw new InvalidOperationException($"Unexpected target: {target}")))); }, (msg, _) => throw new InvalidOperationException($"Unexpected message: {msg}"), (msg, _) => throw new InvalidOperationException($"Unexpected message: {msg}"))); } }
public static IInvocationStart CreateInvocationStartRequest(this IProtocolMessageFactory factory, string serviceId, Maybe <string> serviceAlias, string methodId) { return(factory.CreateInvocationStartRequest( factory.CreateConsumedMethodReference( factory.CreateConsumedServiceReference(serviceId, serviceAlias), methodId), null)); }
public IClientToBrokerRequest DeserializeClientToBrokerRequest(IPooledBuffer message) { using (var envelope = ClientToBrokerRequestEnvelope.Rent()) { envelope.MergeFrom(message); switch (envelope.PayloadCase) { case ClientToBrokerRequestEnvelope.PayloadOneofCase.InvocationStartRequest: var invocationRequest = envelope.InvocationStartRequest; IInvocationTarget target; switch (invocationRequest.TargetCase) { case InvocationStartRequest.TargetOneofCase.ConsumedMethod: target = ConvertFromProtoStrict(invocationRequest.ConsumedMethod); break; case InvocationStartRequest.TargetOneofCase.ProvidedMethod: target = ConvertFromProtoStrict(invocationRequest.ProvidedMethod); break; default: throw new InvalidOperationException($"Unexpected target payload: {invocationRequest.TargetCase}"); } var contextLinkageOptions = ConvertFromProtoStrict(invocationRequest.ContextLinkageOptions); return(_messageFactory.CreateInvocationStartRequest(target, contextLinkageOptions)); case ClientToBrokerRequestEnvelope.PayloadOneofCase.ServiceDiscoveryRequest: return(ConvertFromProtoStrict(envelope.ServiceDiscoveryRequest)); case ClientToBrokerRequestEnvelope.PayloadOneofCase.MethodDiscoveryRequest: return(ConvertFromProtoStrict(envelope.MethodDiscoveryRequest)); default: throw new InvalidOperationException(); } } }