public void Reply_TestEverything() { Reply r1 = new Reply(); Assert.IsFalse(r1.Success); Assert.IsNull(r1.Note); Reply r2 = new Reply() { Success = true, Note = "Testing" }; Assert.IsTrue(r2.Success); Assert.AreEqual("Testing", r2.Note); byte[] bytes = r2.Encode(); string tmp = Encoding.ASCII.GetString(bytes); Message m2 = Message.Decode(bytes); Reply r3 = m2 as Reply; Assert.IsNotNull(r3); Assert.AreNotSame(r2, r3); Assert.IsTrue(r3.Success); Assert.AreEqual(r2.Note, r3.Note); }
public void doWork() { Thread.Sleep(3000); IPEndPoint loginTarget = getEndpont(ConfigurationManager.AppSettings["registryIP"], ConfigurationManager.AppSettings["registryPort"]); bool running = true; while (running) { Program.socket.Connect(loginTarget); var receivedData = Program.socket.Receive(ref loginTarget); Message aRMessage = Message.Decode(receivedData); AliveRequest myAR = aRMessage as AliveRequest; Reply alive = new Reply { Success = true }; byte[] aReply = alive.Encode(); Program.socket.Send(aReply, aReply.Length); Console.WriteLine("Responded to Alive."); } }