Example #1
0
        public static void Main(string[] args)
        {
            string serverAddress = DEFAULT_SERVER_ADDRESS;
            int    serverPort    = DEFAULT_SERVER_PORT;

            LifxClient.Debug.LineLogged += (object sender, LifxClient.DebugLineEventArgs eventArgs) => {
                if (!eventArgs.LogLine.Contains("Type = StateService"))
                {
                    WriteLog("verbose", "[LIFX] " + eventArgs.LogLine, eventArgs.LineNumber, eventArgs.CallerName);
                }
            };

            foreach (string arg in args)
            {
                string[] parts = arg.Split('=');
                switch (parts[0].ToLower())
                {
                case "server":
                    serverAddress = parts[1];
                    break;

                default:
                    Console.WriteLine("Warning: Unknown command line argument " + parts[0]);
                    break;
                }
            }

            HSPI plugin = new HSPI();

            Console.WriteLine("Plugin " + plugin.Name + " is connecting to HS3 at " + serverAddress + ":" + serverPort);
            try {
                plugin.Connect(serverAddress, serverPort);
                Console.WriteLine("Connection established");
            }
            catch (Exception ex) {
                Console.WriteLine("Unable to connect to HS3: " + ex.Message);
                return;
            }

            try {
                while (true)
                {
                    System.Threading.Thread.Sleep(250);
                    if (!plugin.Connected)
                    {
                        Console.WriteLine("Connection to HS3 lost!");
                        break;
                    }

                    if (plugin.Shutdown)
                    {
                        Console.WriteLine("Plugin has been shut down; exiting");
                        break;
                    }
                }
            }
            catch (Exception ex) {
                Console.WriteLine("Unhandled exception: " + ex.Message);
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            //Create a new instance of the plugin class
            _plugin = new HSPI();

            //Perform any initialization that needs to occur before a connection is made to HomeSeer

            //Attempt to connect to HomeSeer
            _plugin.Connect(args);
        }