public void Update()
        {
            if (running)
            {
                CheckConnection();
            }

            IRTCommand toExecute = null;

            while ((toExecute = GetNextAction()) != null)
            {
                toExecute.Execute();
            }
        }
Пример #2
0
        protected void OnPacketReceived(Packet p, int packetSize)
        {
            if (p.Command != null)
            {
#if __WINDOWS__
                if (typeof(AbstractResult).GetTypeInfo().IsAssignableFrom(p.Command.GetType().GetTypeInfo()))
                {
#else
                if (typeof(AbstractResult).IsAssignableFrom(p.Command.GetType()))
                {
#endif
                    AbstractResult result = ((AbstractResult)p.Command);
                    result.Configure(p, session);
                    if (result.ExecuteAsync())
                    {
                        session.SubmitAction(p.Command);
                    }
                    else
                    {
                        p.Command.Execute();
                    }
                }
                else
                {
                    session.SubmitAction(p.Command);
                }
            }
            else
            {
                //If it has a payload, we've already got the IRTCommand from the user
                if (!p.hasPayload)
                {
                    IRTCommand cmd = CustomCommand.pool.Pop().Configure(p.OpCode, p.Sender.GetValueOrDefault(0), null, p.Data, 0, session, packetSize);
                    if (cmd != null)
                    {
                        session.SubmitAction(cmd);
                    }
                }
            }
        }
    }
Пример #3
0
        public RTAction(IRTSender sender, IRTCommand command)
        {
            this.sender                      = sender;
            this.sender.Queued              += OnQueuedHdl;
            this.sender.Dropped             += OnDroppedHdl;
            this.sender.Started             += OnStartedHdl;
            this.sender.Completed           += OnCompletedHdl;
            this.sender.Failed              += OnFailedHdl;
            this.sender.EmptySlotAppeared   += OnEmptySlotHdl;
            this.sender.EmptySlotsEnded     += OnEmptySlotsEndedHdl;
            this.sender.SlotsNumberReceived += OnSpaceReceived;
            Command = command;

            ContiniousBlockCompleted = new EventWaitHandle(false, EventResetMode.ManualReset);
            ReadyToRun = new EventWaitHandle(sender.HasSlots, EventResetMode.ManualReset);
            Started    = new EventWaitHandle(false, EventResetMode.ManualReset);
            Finished   = new EventWaitHandle(false, EventResetMode.ManualReset);

            Failed    = false;
            Aborted   = false;
            CommandId = -1;
        }
 public void SubmitAction(IRTCommand action)
 {
     lock (actionQueue) {
         actionQueue.Enqueue(action);
     }
 }