Beispiel #1
0
        static void Main(string[] args)
        {
            StaticInitHelper.Run(true);

            ServiceHost svcHost = null;

            try
            {
                string URL = "http://127.0.0.1:10001/app/backend/appexample";
                svcHost = SelfHost.Create(URL,
                                          typeof(WcfEntryPoint), typeof(WcfInterface));
            }
            catch (Exception eX)
            {
                svcHost = null;
                Console.WriteLine("Service can not be started \n\nError Message [" + eX.Message + "]");
            }

            if (svcHost != null)
            {
                Console.WriteLine("Running");
                for (;;)
                {
                    Thread.Sleep(1000);
                }
                svcHost.Close();
                svcHost = null;
            }
            StaticInitHelper.Run(false);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            StaticInitHelper.Run(true);

            ServiceHost svcHost = null;

            try
            {
                string URL = "http://127.0.0.1:10123/app/backend/norma";
                svcHost = SelfHost.Create(URL,
                                          typeof(WcfEntryPoint), typeof(WcfInterface));
            }
            catch (Exception eX)
            {
                svcHost = null;
                Console.WriteLine("Service can not be started \n\nError Message [" + eX.Message + "]");
            }

            if (svcHost != null)
            {
                Console.WriteLine("Running");
                for (;;)
                {
                    Thread.Sleep(1000);
                }

                /*
                 * Console.WriteLine("\nPress any key to close the Service");
                 *              for (;;) {
                 *                      ConsoleKeyInfo i = Console.ReadKey ();
                 *                      if (i.KeyChar != '\0')
                 *                              break;
                 *                      Thread.Sleep (100);
                 *              }*/
                svcHost.Close();
                svcHost = null;
            }

            StaticInitHelper.Run(false);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            StaticInitHelper.Run(true);

            ServiceHost svcHost = null;

            try
            {
                string URL = "http://127.0.0.1:10011/app/backend/nurapisample";
                svcHost = SelfHost.Create(URL,
                                          typeof(WcfEntryPoint), typeof(WcfInterface));
            }
            catch (Exception ex)
            {
                svcHost = null;
                Console.WriteLine("Service can not be started \n\nError Message [" + ex.Message + "]");
            }

            try
            {
                // init the nurapi instance
                hNur = new NurApi();
                // add the events we need
                hNur.InventoryStreamEvent += HNur_InventoryStreamEvent;
                hNur.ConnectedEvent       += HNur_ConnectedEvent;
                hNur.DisconnectedEvent    += HNur_DisconnectedEvent;
                // connect to the local instance(127.0.0.1:4333 is the default setting, modify this to fit your needs)
                hNur.ConnectSocket("127.0.0.1", 4333);
            }
            catch (Exception eX)
            {
                svcHost = null;
                Console.WriteLine("Could not init NurApi instance [" + eX.Message + "]");
            }

            try
            {
                client = new Nmqtt.MqttClient("localhost", 1883, "nurapisample");
                ConnectionState connectionState = client.Connect();
                Console.WriteLine("MQTT connection state is [" + connectionState + "]");
            }
            catch (Exception ex)
            {
                svcHost = null;
                Console.WriteLine("Could not init MQTT instance [" + ex.Message + "]");
            }

            if (svcHost != null)
            {
                Console.WriteLine("Running");
                for (;;)
                {
                    Thread.Sleep(1000);
                }
                svcHost.Close();
                svcHost = null;
            }

            if (svcHost != null)
            {
                StaticInitHelper.Run(false);
            }
        }