Beispiel #1
0
        public ActorMessageEnvelope <P> SendMessage <R, P>(string remoteActorType, ActorMessageEnvelope <R> request, TimeSpan timeout)
        {
            ActorMessageEnvelope <P>           response = default(ActorMessageEnvelope <P>);
            Action <ActorMessageEnvelope <P> > callback = (r) => { response = r; };

            try
            {
                ManualResetEvent waiter = new ManualResetEvent(false);
                _callbacks.Add(request.MessageID, new BlockingCallbackHolder(request.MessageID, waiter, callback));

                this.BeginSend(remoteActorType, request.ToBytes(this.Encoder));

                if (!waiter.WaitOne(timeout))
                {
                    _log.ErrorFormat("Timeout when waiting message [{0}] after {1} seconds.",
                                     request.MessageType, timeout.TotalSeconds);
                }
                waiter.Reset();
                waiter.Dispose();
                BlockingCallbackHolder throwAway = null;
                _callbacks.TryRemove(request.MessageID, out throwAway);
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex);
            }

            return(response);
        }
Beispiel #2
0
 public void Send <T>(string remoteActorType, ActorMessageEnvelope <T> message)
 {
     BeginSend(remoteActorType, message.ToBytes(this.Encoder));
 }
Beispiel #3
0
 public IAsyncResult BeginSend <T>(string remoteActorType, string remoteActorName, ActorMessageEnvelope <T> message, AsyncCallback callback, object state)
 {
     return(BeginSend(remoteActorType, remoteActorName, message.ToBytes(this.Encoder), callback, state));
 }
Beispiel #4
0
 public IAsyncResult BeginSend <T>(ActorIdentity remoteActor, ActorMessageEnvelope <T> message, AsyncCallback callback, object state)
 {
     return(BeginSend(remoteActor, message.ToBytes(this.Encoder), callback, state));
 }
Beispiel #5
0
 public void BeginSend <T>(ActorIdentity remoteActor, ActorMessageEnvelope <T> message)
 {
     BeginSend(remoteActor, message.ToBytes(this.Encoder));
 }
Beispiel #6
0
 public void BeginBroadcast <T>(string remoteActorType, ActorMessageEnvelope <T> message)
 {
     BeginBroadcast(remoteActorType, message.ToBytes(this.Encoder));
 }
Beispiel #7
0
 public void BeginBroadcast <T>(IEnumerable <string> remoteActorTypes, ActorMessageEnvelope <T> message)
 {
     BeginBroadcast(remoteActorTypes, message.ToBytes(this.Encoder));
 }
Beispiel #8
0
 public void BeginReply <T>(string channelIdentifier, ActorMessageEnvelope <T> message)
 {
     BeginReply(channelIdentifier, message.ToBytes(this.Encoder));
 }