Esempio n. 1
0
        public override bool Equals(object obj)
        {
            SolutionRequestMessage message = obj as SolutionRequestMessage;


            return(Id == message.Id);
        }
          /******************************************************************/
        /************************** CONSTRUCTORS **************************/
        /******************************************************************/

        /// <summary>
        ///     Creates KeepAliveTimer
        /// </summary>
        /// <param name="messageProcessor"></param>
        /// /// <param name="systemTracker"></param>
        public ComputationalClientCheckTimer(MessageProcessor messageProcessor, ClientSystemTracker systemTracker, ulong id)
        {
            solutionRequestMessage = new SolutionRequestMessage(id);

            this.messageProcessor = messageProcessor;
            this.systemTracker = systemTracker;

            // TODO Magic numbers
            this.timer = new System.Timers.Timer((systemTracker.Node.Timeout * 1000) / 2);
            this.timer.Elapsed += keepAlive;

            Active = false;
        }
        /*******************************************************************/
        /************************* PUBLIC METHODS **************************/
        /*******************************************************************/

        public void Start(ulong id)
        {
            solutionRequestMessage = new SolutionRequestMessage(id);

            this.timer = new System.Timers.Timer((systemTracker.Node.Timeout * 1000) / KEEP_ALIVE_SCALLAR);
            this.timer.Elapsed += keepAliveSolution;

            this.timer.Enabled = true;
        }
        public void Parse_XMLString_SolutionRequestMessage()
        {
            /*********** Actual message ***********/
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\SolutionRequest.xml");

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(path);
            string xmlStr = xmlDoc.OuterXml;

            string name = Message.GetMessageName(xmlStr);
            SolutionRequestMessage actualMessage = null;

            if (name == SolutionRequestMessage.ELEMENT_NAME)
                actualMessage = SolutionRequestMessage.Construct(xmlStr);

            /*********** Expected message ***********/
            ulong id = 9;

            SolutionRequestMessage expectedMessage = new SolutionRequestMessage(id);

            Assert.AreEqual(expectedMessage, actualMessage);
        }
        public void Parse_SolutionRequestMessage_XMLString()
        {
            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\SolutionRequest.xml");

            ulong id = 9;

            SolutionRequestMessage message = new SolutionRequestMessage(id);

            //message.ToXmlFile(path);

            string actualXmlStr = message.ToXmlString();

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(path);
            string expectedXmlStr = xmlDoc.OuterXml;

            Assert.AreEqual(expectedXmlStr, actualXmlStr);
        }
Esempio n. 6
0
        public static SolutionRequestMessage CreateSolutionRequestMessage()
        {
            ulong id = 9;

            SolutionRequestMessage expectedMessage = new SolutionRequestMessage(id);
            return expectedMessage;
        }