Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //find server via UDP broadcast
            bool       done     = false;
            string     otpip    = "";
            UdpClient  listener = new UdpClient(discoveryPort);
            IPEndPoint groupEP  = new IPEndPoint(IPAddress.Any, discoveryPort);

            try
            {
                while (!done)
                {
                    Console.WriteLine("Waiting for server");
                    byte[] bytes = listener.Receive(ref groupEP);

                    var ipAddress = new IPAddress(bytes);
                    otpip = "http://" + ipAddress + ":8088/OTB";
                    done  = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                listener.Close();
            }

            OTBClient client = new OTBClient(otpip);

            if (client.Start())
            {
                client.RunMessageLoop();
            }
        }