public Task<System.Int32> Echo(System.Int32 value)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IServer_PayloadTable.Echo_Invoke { value = value }
     };
     return SendRequestAndReceive<System.Int32>(requestMessage);
 }
 public Task<string> Greet(string name)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IGreeter_PayloadTable.Greet_Invoke { name = name }
     };
     return SendRequestAndReceive<string>(requestMessage);
 }
 public Task Unsubscribe(HelloWorld.Interface.IGreetObserver observer)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IGreeterWithObserver_PayloadTable.Unsubscribe_Invoke { observer = (GreetObserver)observer }
     };
     return SendRequestAndWait(requestMessage);
 }
 public Task<HelloWorld.Interface.IGreeterWithObserver> GetGreeter()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IEntry_PayloadTable.GetGreeter_Invoke {  }
     };
     return SendRequestAndReceive<HelloWorld.Interface.IGreeterWithObserver>(requestMessage);
 }
 public Task Unsubscribe(Akka.Interfaced.SlimServer.ISubjectObserver observer)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ISubject_PayloadTable.Unsubscribe_Invoke { observer = (SubjectObserver)observer }
     };
     return SendRequestAndWait(requestMessage);
 }
 void ISubject_NoReply.Unsubscribe(Akka.Interfaced.SlimServer.ISubjectObserver observer)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ISubject_PayloadTable.Unsubscribe_Invoke { observer = (SubjectObserver)observer }
     };
     SendRequest(requestMessage);
 }
 void ICalculator_NoReply.Sum(int a, int b)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICalculator_PayloadTable.Sum_Invoke { a = a, b = b }
     };
     SendRequest(requestMessage);
 }
 void IDummyWithTag_NoReply.CallWithTag(object param, string id)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IDummyWithTag_PayloadTable.CallWithTag_Invoke { param = param, id = id }
     };
     SendRequest(requestMessage);
 }
 public Task<int> Sum(System.Tuple<int, int> v)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICalculator_PayloadTable.Sum_2_Invoke { v = v }
     };
     return SendRequestAndReceive<int>(requestMessage);
 }
 void ICalculator_NoReply.Concat(string a, string b)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICalculator_PayloadTable.Concat_Invoke { a = a, b = b }
     };
     SendRequest(requestMessage);
 }
 public Task<int> Sum(int a, int b)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICalculator_PayloadTable.Sum_Invoke { a = a, b = b }
     };
     return SendRequestAndReceive<int>(requestMessage);
 }
 public Task<string> Concat(string a, string b)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICalculator_PayloadTable.Concat_Invoke { a = a, b = b }
     };
     return SendRequestAndReceive<string>(requestMessage);
 }
Ejemplo n.º 13
0
        Task <TReturn> IRequestWaiter.SendRequestAndReceive <TReturn>(IRequestTarget target, RequestMessage request, TimeSpan?timeout)
        {
            if (_requestWaiter == null)
            {
                _requestWaiter = new InterfacedActorRequestWaiter();
            }

            return(_requestWaiter.SendRequestAndReceive <TReturn>(target, request, Self, timeout));
        }
 void IGreeter_NoReply.GetCount()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IGreeter_PayloadTable.GetCount_Invoke {  }
     };
     SendRequest(requestMessage);
 }
 void ICalculator_NoReply.Sum(System.Tuple<int, int> v)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICalculator_PayloadTable.Sum_2_Invoke { v = v }
     };
     SendRequest(requestMessage);
 }
Ejemplo n.º 16
0
        // from IRequestWaiter

        void IRequestWaiter.SendRequest(IRequestTarget target, RequestMessage requestMessage)
        {
            var sender = ActorCell.GetCurrentSelfOrNoSender();

            ((AkkaReceiverTarget)target).Receiver.Tell(requestMessage, sender);
        }
 public Task IncCounter(int delta)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICounter_PayloadTable.IncCounter_Invoke { delta = delta }
     };
     return SendRequestAndWait(requestMessage);
 }
 public Task MakeEvent(string eventName)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ISubject_PayloadTable.MakeEvent_Invoke { eventName = eventName }
     };
     return SendRequestAndWait(requestMessage);
 }
 void ICounter_NoReply.IncCounter(int delta)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ICounter_PayloadTable.IncCounter_Invoke { delta = delta }
     };
     SendRequest(requestMessage);
 }
 void ISubject_NoReply.MakeEvent(string eventName)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new ISubject_PayloadTable.MakeEvent_Invoke { eventName = eventName }
     };
     SendRequest(requestMessage);
 }
 public Task<UnityBasic.Interface.ICounter> GetCounter()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IEntry_PayloadTable.GetCounter_Invoke {  }
     };
     return SendRequestAndReceive<UnityBasic.Interface.ICounter>(requestMessage);
 }
 public Task<object> Call(object param)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IDummy_PayloadTable.Call_Invoke { param = param }
     };
     return SendRequestAndReceive<object>(requestMessage);
 }
 public Task<UnityBasic.Interface.IGreeterWithObserver> GetGreeterOnAnotherChannel()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IEntry_PayloadTable.GetGreeterOnAnotherChannel_Invoke {  }
     };
     return SendRequestAndReceive<UnityBasic.Interface.IGreeterWithObserver>(requestMessage);
 }
 void IServer_NoReply.Echo(System.Int32 value)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IServer_PayloadTable.Echo_Invoke { value = value }
     };
     SendRequest(requestMessage);
 }
 public Task<UnityBasic.Interface.IPedantic> GetPedantic()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IEntry_PayloadTable.GetPedantic_Invoke {  }
     };
     return SendRequestAndReceive<UnityBasic.Interface.IPedantic>(requestMessage);
 }
 void IEntry_NoReply.GetGreeter()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IEntry_PayloadTable.GetGreeter_Invoke {  }
     };
     SendRequest(requestMessage);
 }
 void IEntry_NoReply.GetPedantic()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IEntry_PayloadTable.GetPedantic_Invoke {  }
     };
     SendRequest(requestMessage);
 }
 public Task<int> GetCount()
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IGreeter_PayloadTable.GetCount_Invoke {  }
     };
     return SendRequestAndReceive<int>(requestMessage);
 }
 void IDummyEx2_NoReply.CallEx2(object param)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IDummyEx2_PayloadTable.CallEx2_Invoke { param = param }
     };
     SendRequest(requestMessage);
 }
 void IGreeterWithObserver_NoReply.Unsubscribe(HelloWorld.Interface.IGreetObserver observer)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IGreeterWithObserver_PayloadTable.Unsubscribe_Invoke { observer = (GreetObserver)observer }
     };
     SendRequest(requestMessage);
 }
 public Task<object> CallWithTag(object param, string id = null)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IDummyWithTag_PayloadTable.CallWithTag_Invoke { param = param, id = id }
     };
     return SendRequestAndReceive<object>(requestMessage);
 }
 void IGreeter_NoReply.Greet(string name)
 {
     var requestMessage = new RequestMessage {
         InvokePayload = new IGreeter_PayloadTable.Greet_Invoke { name = name }
     };
     SendRequest(requestMessage);
 }
Ejemplo n.º 33
0
        private void OnRequestMessage(RequestMessage request)
        {
            var sender = base.Sender;

            if (request.InvokePayload == null)
            {
                sender.Tell(new ResponseMessage
                {
                    RequestId = request.RequestId,
                    Exception = new RequestMessageException("Empty payload")
                });
                Context.System.EventStream.Publish(new Event.Warning(
                                                       Self.Path.ToString(), GetType(),
                                                       $"Receives a bad request without payload from {Sender}"));
                return;
            }

            var payloadType = request.InvokePayload.GetType();
            var handlerItem = _handler.RequestDispatcher.GetHandler(payloadType);

            if (handlerItem == null)
            {
                // if generic argument, try to instantiate a generic handler by the given payload type.

                if (payloadType.IsGenericType)
                {
                    var genericHandlerItem = _handler.RequestDispatcher.GetHandler(payloadType.GetGenericTypeDefinition());
                    if (genericHandlerItem != null)
                    {
                        handlerItem = genericHandlerItem.GenericHandlerBuilder(payloadType);
                        _handler.RequestDispatcher.AddHandler(payloadType, handlerItem);
                    }
                }

                // oops, no handler.

                if (handlerItem == null)
                {
                    sender.Tell(new ResponseMessage
                    {
                        RequestId = request.RequestId,
                        Exception = new RequestHandlerNotFoundException()
                    });
                    Context.System.EventStream.Publish(new Event.Warning(
                                                           Self.Path.ToString(), GetType(),
                                                           $"Cannot find a handler for request {payloadType} from {Sender}"));
                    return;
                }
            }

            if (handlerItem.Handler != null)
            {
                // sync handle

                handlerItem.Handler(this, request, (response, exception) =>
                {
                    if (request.RequestId != 0)
                    {
                        sender.Tell(response);
                    }

                    if (exception != null)
                    {
                        ((ActorCell)Context).InvokeFailure(exception);
                    }
                });
            }
            else
            {
                // async handle

                var context = new MessageHandleContext {
                    Self = Self, Sender = base.Sender, CancellationToken = CancellationToken, RequestId = request.RequestId
                };
                if (handlerItem.IsReentrant)
                {
                    _activeReentrantCount += 1;
                    if (request.RequestId != 0)
                    {
                        if (_activeReentrantAsyncRequestSet == null)
                        {
                            _activeReentrantAsyncRequestSet = new HashSet <MessageHandleContext>();
                        }

                        _activeReentrantAsyncRequestSet.Add(context);
                    }
                }
                else
                {
                    BecomeStacked(OnReceiveInAtomicTask);
                    _currentAtomicContext = context;
                }

                using (new SynchronizationContextSwitcher(new ActorSynchronizationContext(context)))
                {
                    var requestId   = request.RequestId;
                    var isReentrant = handlerItem.IsReentrant;
                    handlerItem.AsyncHandler(this, request, (response, exception) =>
                    {
                        if (requestId != 0)
                        {
                            if (isReentrant)
                            {
                                _activeReentrantAsyncRequestSet.Remove(context);
                            }

                            sender.Tell(response);
                        }

                        OnTaskCompleted(exception, isReentrant);
                    });
                }
            }
        }