Exemple #1
0
 public void Utilize(int limit, TimeSpan Time, out string log)
 {
     log = "";
     for (int i = 0; i < TimeMessage.Count; i++)
     {
         if (Time.Subtract(TimeMessage[i]).TotalSeconds > limit)
         {
             for (int f = 0; f < Edges.Count; f++)
             {
                 if (TimeEdges[i].Equals(Edges[f]))
                 {
                     if (EdgeWeight[f] > 1)
                     {
                         log           += "Edge #" + No + " & Edge # " + Edges[f].No + " get low\n";
                         EdgeWeight[f] -= 1;
                         TimeEdges.RemoveAt(i);
                         TimeMessage.RemoveAt(i);
                         break;
                     }
                     else
                     {
                         log += "Edge #" + No + " & Edge # " + Edges[f].No + " delete\n";
                         Edges.RemoveAt(f);
                         EdgeWeight.RemoveAt(f);
                         TimeEdges.RemoveAt(i);
                         TimeMessage.RemoveAt(i);
                         break;
                     }
                 }
             }
             --i;
         }
     }
 }
Exemple #2
0
 public void SendInformalMessage(Node recipient, TimeSpan time)
 {
     TimeEdges.Add(recipient);
     TimeMessage.Add(time);
     this.SendMessage(recipient);
     recipient.ReceiveInformaion(this, time);
 }
Exemple #3
0
        public static P3bbleMessage CreateMessage(P3bbleEndpoint endpoint, List <byte> payload)
        {
            P3bbleMessage frame = null;

            switch (endpoint)
            {
            case P3bbleEndpoint.Ping:
                frame = new PingMessage();
                break;

            case P3bbleEndpoint.Version:
                frame = new VersionMessage();
                break;

            case P3bbleEndpoint.Time:
                frame = new TimeMessage();
                break;

            case P3bbleEndpoint.Logs:
                frame = new LogsMessage();
                break;

            default:
                frame = new P3bbleMessage(endpoint);
                break;
            }

            frame.GetContentFromMessage(payload);
            return(frame);
        }
Exemple #4
0
 private void OnTime(TimeMessage message)
 {
     GetService <IDispatcherService>()
     .BeginInvoke(() =>
     {
         GetService <IMessageBoxService>()
         .Show(message.EventItem.Description, DisplayTitle, MessageBoxButton.OK, MessageBoxImage.Information);
     });
 }
Exemple #5
0
 //TODO: Put this in its own class
 IEnumerator SyncClock()
 {
     while (GameManager.instance.gameRunning)
     {
         activeTimeMessage = new TimeMessage();
         SendTCP(activeTimeMessage);
         yield return(new WaitForSeconds(1));
     }
 }
Exemple #6
0
        public void TimeMessage_at_breakfast_as_expected()
        {
            //Arrange
            ClockMechanicsBreakfastStub clockMechanicsdBreakfastStub = new ClockMechanicsBreakfastStub();

            //Act
            TimeMessage timeMessage = new TimeMessage(clockMechanicsdBreakfastStub);

            //Assert
            Assert.Equal(timeMessage.FriendlyFormatTime, "15 past 7 in the ante meridiem on August, 22nd of 2003");
        }
Exemple #7
0
        public void TimeMessage_at_dinner_as_expected()
        {
            //Arrange
            ClockMechanicsDinnerStub clockMechanicsdDinnerStub = new ClockMechanicsDinnerStub();

            //Act
            TimeMessage timeMessage = new TimeMessage(clockMechanicsdDinnerStub);

            //Assert
            Assert.Equal(timeMessage.FriendlyFormatTime, "6 past 8 in the post meridiem on November, 23rd of 2017");
        }
Exemple #8
0
        public void TimeMessage_at_lunch_as_expected()
        {
            //Arrange
            ClockMechanicsLunchStub clockMechanicsdLunchStub = new ClockMechanicsLunchStub();

            //Act
            TimeMessage timeMessage = new TimeMessage(clockMechanicsdLunchStub);

            //Assert
            Assert.Equal(timeMessage.FriendlyFormatTime, "0 past noon on February, 29th of 1996");
        }
Exemple #9
0
        /// <summary>
        /// Creates an incoming message.
        /// </summary>
        /// <param name="endpoint">The endpoint.</param>
        /// <param name="payload">The payload.</param>
        /// <returns>A specific message type</returns>
        public static P3bbleMessage CreateMessage(Endpoint endpoint, List <byte> payload)
        {
            P3bbleMessage frame = null;

            switch (endpoint)
            {
            case Endpoint.Ping:
                frame = new PingMessage();
                break;

            case Endpoint.Version:
                frame = new VersionMessage();
                break;

            case Endpoint.Time:
                frame = new TimeMessage();
                break;

            case Endpoint.Logs:
                frame = new LogsMessage();
                break;

            case Endpoint.AppManager:
                frame = new AppManagerMessage();
                break;

            case Endpoint.MusicControl:
                frame = new MusicMessage();
                break;

            case Endpoint.ApplicationMessage:
                frame = new AppMessage(endpoint);
                break;

            case Endpoint.PutBytes:
                frame = new PutBytesMessage();
                break;
            }

            if (frame != null)
            {
                frame.GetContentFromMessage(payload);
            }

            return(frame);
        }
Exemple #10
0
    public bool Receive(out Message msg)
    {
        msg.isRedRoller = false;
        msg.code        = ControlCode.Illegal;
        msg.yes         = false;
        if (msgQueue.Count == 0)
        {
            return(false);
        }
        TimeMessage timeMsg = msgQueue.Peek();

        if (timeMsg.time >= Time.time)
        {
            return(false);
        }

        msgQueue.Dequeue();
        msg = timeMsg.msg;
        return(true);
    }
        void OnTimeMessageBack(IMessageBase baseMessage)
        {
            TimeMessage message = (TimeMessage)baseMessage;

            double nowMillis   = Time.NowMilliseconds;
            double deltaMillis = nowMillis - message.Millis;

            if (!_lastRoundTripTimes.ContainsKey(message.UserId))
            {
                _lastRoundTripTimes[message.UserId] = new History(3);
            }

            History playerHistory = _lastRoundTripTimes[message.UserId];

            playerHistory.AddFront(deltaMillis);

            if (deltaMillis > 50)
            {
                Logger.Trace($"Roundtrip to {message.UserId} took {deltaMillis}ms (single: {deltaMillis / 2}, avg single: {playerHistory.Average / 2})");
            }
        }
Exemple #12
0
 public GoalIDMessage(TimeMessage stamp, string id)
 {
     this.stamp = stamp;
     this.id    = id;
 }
 public ClockMessage(TimeMessage clock)
 {
     this.clock = clock;
 }
Exemple #14
0
 public Task Handle(TimeMessage message)
 {
     Logger.Info(message);
     return(Task.FromResult <object>(null));
 }
Exemple #15
0
 protected void ReceiveInformaion(Node sender, TimeSpan time)
 {
     TimeEdges.Add(sender);
     TimeMessage.Add(time);
 }
Exemple #16
0
        public TimeMessage Get()
        {
            TimeMessage timeMessage = new TimeMessage(_clockMechanics);

            return(timeMessage);
        }
 //REPLACE
 //This function sends the current in-game time to the client requesting time.
 private void OnServerRecieveTimeRequest(NetworkMessage netMsg)
 {
     TimeMessage timeMessage = new TimeMessage();
     timeMessage.time = timerRound;
     NetworkServer.SendToClient(IDFromConn(netMsg.conn), Msgs.sendCurrentTime, timeMessage);
 }
Exemple #18
0
        /// <summary>
        /// Finds a message type to handle the message.
        /// </summary>
        public ReceivableMessage Process()
        {
            // Named messages.
            if (NickMessage.CanProcess(this))
            {
                return(new NickMessage(this));
            }
            if (QuitMessage.CanProcess(this))
            {
                return(new QuitMessage(this));
            }
            if (JoinMessage.CanProcess(this))
            {
                return(new JoinMessage(this));
            }
            if (PartMessage.CanProcess(this))
            {
                return(new PartMessage(this));
            }
            if (PrivateMessage.CanProcess(this))
            {
                return(new PrivateMessage(this));
            }
            if (PingMessage.CanProcess(this))
            {
                return(new PingMessage(this));
            }
            if (NoticeMessage.CanProcess(this))
            {
                return(new NoticeMessage(this));
            }
            if (UserModeMessage.CanProcess(this))
            {
                return(new UserModeMessage(this));
            }
            if (ChannelModeMessage.CanProcess(this))
            {
                return(new ChannelModeMessage(this));
            }
            if (KickMessage.CanProcess(this))
            {
                return(new KickMessage(this));
            }
            if (InviteMessage.CanProcess(this))
            {
                return(new InviteMessage(this));
            }
            if (OperwallMessage.CanProcess(this))
            {
                return(new OperwallMessage(this));
            }
            if (Receive.TopicMessage.CanProcess(this))
            {
                return(new Receive.TopicMessage(this));
            }

            // IRCv3 messages.
            if (Receive.v3.CapabilityMessage.CanProcess(this))
            {
                return(new Receive.v3.CapabilityMessage(this));
            }
            if (Receive.v3.AwayMessage.CanProcess(this))
            {
                return(new Receive.v3.AwayMessage(this));
            }

            // Numerics.
            if (NumericMessage.CanProcess(this))
            {
                // Pass all numeric messages to NumericMessage so an event can be fired, then pass it to more specific instances.
                // ReSharper disable once ObjectCreationAsStatement
                new NumericMessage(this);

                if (WelcomeMessage.CanProcess(this))
                {
                    return(new WelcomeMessage(this));
                }
                if (YourHostMessage.CanProcess(this))
                {
                    return(new YourHostMessage(this));
                }
                if (CreatedMessage.CanProcess(this))
                {
                    return(new CreatedMessage(this));
                }
                if (MyInfoMessage.CanProcess(this))
                {
                    return(new MyInfoMessage(this));
                }
                if (SupportMessage.CanProcess(this))
                {
                    return(new SupportMessage(this));
                }
                if (BounceMessage.CanProcess(this))
                {
                    return(new BounceMessage(this));
                }
                if (MOTDEndMessage.CanProcess(this))
                {
                    return(new MOTDEndMessage(this));
                }
                if (MOTDStartMessage.CanProcess(this))
                {
                    return(new MOTDStartMessage(this));
                }
                if (MOTDMessage.CanProcess(this))
                {
                    return(new MOTDMessage(this));
                }
                if (LUserMessage.CanProcess(this))
                {
                    return(new LUserMessage(this));
                }
                if (NamesMessage.CanProcess(this))
                {
                    return(new NamesMessage(this));
                }
                if (EndOfNamesMessage.CanProcess(this))
                {
                    return(new EndOfNamesMessage(this));
                }
                if (TopicMessage.CanProcess(this))
                {
                    return(new TopicMessage(this));
                }
                if (TopicWhoTimeMessage.CanProcess(this))
                {
                    return(new TopicWhoTimeMessage(this));
                }
                if (ListMessage.CanProcess(this))
                {
                    return(new ListMessage(this));
                }
                if (ListEndMessage.CanProcess(this))
                {
                    return(new ListEndMessage(this));
                }
                if (YoureOperMessage.CanProcess(this))
                {
                    return(new YoureOperMessage(this));
                }
                if (AwayMessage.CanProcess(this))
                {
                    return(new AwayMessage(this));
                }
                if (UnAwayMessage.CanProcess(this))
                {
                    return(new UnAwayMessage(this));
                }
                if (NowAwayMessage.CanProcess(this))
                {
                    return(new NowAwayMessage(this));
                }
                if (ChannelModeIsMessage.CanProcess(this))
                {
                    return(new ChannelModeIsMessage(this));
                }
                if (UModeIsMessage.CanProcess(this))
                {
                    return(new UModeIsMessage(this));
                }
                if (VersionMessage.CanProcess(this))
                {
                    return(new VersionMessage(this));
                }
                if (TimeMessage.CanProcess(this))
                {
                    return(new TimeMessage(this));
                }
                if (WhoMessage.CanProcess(this))
                {
                    return(new WhoMessage(this));
                }
                if (WhoisMessage.CanProcess(this))
                {
                    return(new WhoisMessage(this));
                }
                if (EndOfWhoMessage.CanProcess(this))
                {
                    return(new EndOfWhoMessage(this));
                }
                if (EndOfWhoisMessage.CanProcess(this))
                {
                    return(new EndOfWhoisMessage(this));
                }
                if (BanListMessage.CanProcess(this))
                {
                    return(new BanListMessage(this));
                }
                if (EndOfBanListMessage.CanProcess(this))
                {
                    return(new EndOfBanListMessage(this));
                }
                if (InviteListMessage.CanProcess(this))
                {
                    return(new InviteListMessage(this));
                }
                if (EndOfInviteListMessage.CanProcess(this))
                {
                    return(new EndOfInviteListMessage(this));
                }
                if (ExceptListMessage.CanProcess(this))
                {
                    return(new ExceptListMessage(this));
                }
                if (EndOfExceptListMessage.CanProcess(this))
                {
                    return(new EndOfExceptListMessage(this));
                }
                if (IsOnMessage.CanProcess(this))
                {
                    return(new IsOnMessage(this));
                }

                // Catch all for unhandled error messages.
                if (ErrorMessage.CanProcess(this))
                {
                    return(new ErrorMessage(this));
                }
            }

            Console.WriteLine("Message handler for \"" + Text + "\" not found.");
            return(null);
        }
 public ClockMessage()
 {
     this.clock = new TimeMessage();
     this.clock.Now();
 }