예제 #1
0
        static void Main(string[] args)
        {
            #region datagram_toString_test
            var d = new Datagram
            {
                Message = "Hali!",
                Timestamp = DateTime.UtcNow,
                Metadata = new Dictionary<string,string>
                {
                    { "a", "b" },
                    { "LEVEL", "Debug" }
                }
            };

            Console.WriteLine(d.ToString());

            var d2 = new Datagram
            {
                Message = "Hali!",
                Timestamp = DateTime.UtcNow
            };
            Console.WriteLine();
            Console.WriteLine(d2.ToString());
            #endregion

            using (var host = new DatagramServiceMexHost(new Uri("http://localhost:8085/test")))
            {
                host.Open();
                Console.WriteLine("Datagram Service is ready.");
                Console.WriteLine(host.Address);

                Console.ReadLine();

                host.ChangeAddress(new Uri("http://localhost:8085/datagram"));
                Console.WriteLine("Datagram Service is rehosted.");
                Console.WriteLine(host.Address);

                Console.ReadLine();
            }

            Console.WriteLine("Datagram Service closed.");

            #region termination_protection
            Console.ReadKey();
            #endregion
        }
 public void ProcessDatagram(Datagram datagram)
 {
     Console.WriteLine(datagram.ToString());
 }