Beispiel #1
0
 public void Process(AsTelegram telegram)
 {
     foreach (var pair in _pairs)
     {
         if (pair.DoesMatch(telegram))
         {
             pair.Action(telegram);
             return;
         }
     }
     Preconditions.Fail("Cannot match telegram " + telegram);
 }
Beispiel #2
0
        public void Update()
        {
            if (_reciever == null)
            {
                _reciever = BuildRecieve(new AsRecieverBuilder());
            }
            var thisFrameIndex    = Time.frameCount;
            var messagesToProcess = _queue.Where(c => c.Timestamp.FrameNo < thisFrameIndex).ToList();

            _queue = new Queue <AsTelegram>(_queue.Where(c => c.Timestamp.FrameNo >= thisFrameIndex).ToList());

            messagesToProcess.ForEach(c =>
            {
                _registry?.RegisterRecievedMessage(this, c);
                _messageBeingRepliedTo = c;
                _reciever.Process(c);
            });

            _messageBeingRepliedTo = null;
            InternalUpdate();
        }
Beispiel #3
0
        protected void SendTelegram(AsAbstractActor destinationActor, object payload)
        {
            var telegram = new AsTelegram()
            {
                Payload   = payload,
                Sender    = this,
                Reciever  = destinationActor,
                Timestamp = new AsTelegramTimestamp()
                {
                    FrameNo      = Time.frameCount,
                    MessageIndex = _lastMessageIndex++
                }
            };

            destinationActor.RecieveTelegram(telegram);
            if (_messageBeingRepliedTo == null)
            {
                _registry?.RegisterInitiatedMessage(this, telegram);
            }
            else
            {
                _registry?.RegisterReplyMessage(this, _messageBeingRepliedTo, telegram);
            }
        }
Beispiel #4
0
 private void RecieveTelegram(AsTelegram telegram)
 {
     _queue.Enqueue(telegram);
 }
Beispiel #5
0
 public override bool DoesMatch(AsTelegram telegram)
 {
     return(true);
 }
Beispiel #6
0
 public override bool DoesMatch(AsTelegram telegram)
 {
     return(telegram.CanCastPayload <T>());
 }
Beispiel #7
0
 public abstract bool DoesMatch(AsTelegram telegram);
Beispiel #8
0
 public bool DoesMatch(AsTelegram telegram)
 {
     return(_matcher.DoesMatch(telegram));
 }