private IActorRemotingMessageHeaders CreateActorHeader(ActorRemotingDispatchHeaders actorDispatchHeaders) { InterfaceDetails details; if (ActorCodeBuilder.TryGetKnownTypes(actorDispatchHeaders.ActorInterfaceName, out details)) { var headers = new ActorRemotingMessageHeaders(); headers.ActorId = actorDispatchHeaders.ActorId; headers.InterfaceId = details.Id; if (String.IsNullOrEmpty(actorDispatchHeaders.CallContext)) { headers.CallContext = Helper.GetCallContext(); } else { headers.CallContext = actorDispatchHeaders.CallContext; } var headersMethodId = 0; if (!details.MethodNames.TryGetValue(actorDispatchHeaders.MethodName, out headersMethodId)) { throw new NotSupportedException("This Actor Method is not Supported" + actorDispatchHeaders.MethodName); } headers.MethodId = headersMethodId; return(headers); } throw new NotSupportedException("This Actor Interface is not Supported" + actorDispatchHeaders.ActorInterfaceName); }
/// <summary> /// Dispatches the messages received from the client to the actor service methods or the actor methods. /// This can be be used by user as an independent dispatcher like short-circuiting. /// </summary> /// <param name="requestBody"></param> /// <param name="cancellationToken"></param> /// <param name="actorDispatchHeaders"></param> /// <returns></returns> public Task <IServiceRemotingResponseMessageBody> HandleRequestResponseAsync( ActorRemotingDispatchHeaders actorDispatchHeaders, IServiceRemotingRequestMessageBody requestBody, CancellationToken cancellationToken) { //For Actor Service Requests if (!string.IsNullOrEmpty(actorDispatchHeaders.ServiceInterfaceName)) { return(base.HandleRequestResponseAsync(actorDispatchHeaders, requestBody, cancellationToken)); } var header = this.CreateActorHeader(actorDispatchHeaders); return(this.HandleActorMethodDispatchAsync(header, requestBody, cancellationToken)); }
public async Task <string> DispatchToActor(ActorId actorId, string actorInterfaceName, string actorMethodName, string dataToProcess) { // Create headers var header = new ActorRemotingDispatchHeaders(); header.ActorId = actorId; header.MethodName = actorMethodName; header.ActorInterfaceName = actorInterfaceName; // Add params var body = this.messageBodyFactory.CreateRequest(actorInterfaceName, actorMethodName, 1); body.SetParameter(0, "dataToProcess", dataToProcess); var response = await this.actorServiceRemotingMessageDispatcher.HandleRequestResponseAsync(header, body, CancellationToken.None); return((string)response.Get(typeof(string))); }