Esempio n. 1
0
        public void DispatchMessage(double delay, int sender, int reciever, msg_type msg, object ExtraInfo)
        {
            BaseEntity pSender   = EntityMgr.GetEntityFromID(sender);
            BaseEntity pReciever = EntityMgr.GetEntityFromID(reciever);

            if (pReciever == null)
            {
                Console.WriteLine("Warning! No Reciever with ID " + reciever + " is found!");
            }

            Telegram telegram = new Telegram(0, sender, reciever, msg, ExtraInfo);

            if (delay <= 0.0f)
            {
                Console.WriteLine("Instant telegram dispatched at time: " + string.Format(" {0:HH:mm:ss tt}", DateTime.Now) + " by " + EntityType.GetEntityName(pSender.ID)
                                  + " for " + EntityType.GetEntityName(pReciever.ID) + ". Message is: " + MsgType.GetMsgName(msg));
                Discharge(pReciever, telegram);
            }
            else
            {
                double currenttime = CrudeTimer.Instance.GetCurrentTime();
                telegram.DispatchTime = currenttime + delay;
                PriorityQ.Add(telegram);
                Console.WriteLine("Delayed telegram from " + EntityType.GetEntityName(pSender.ID) + " recorded at time " + string.Format(" {0:HH:mm:ss tt}", CrudeTimer.Instance.GetCurrentTime()) + " for " + EntityType.GetEntityName(pReciever.ID)
                                  + ". Message is: " + MsgType.GetMsgName(msg));
            }
        }