/// <summary> /// Called when a server is found! Try to connect. /// </summary> /// <param name="ipAddress"></param> public void OnClientFound(string ipAddress) { lock(objectLock) { // Only let one attempt go through at a time if(m_isPendingConnection || IsConnected) { return; } m_isPendingConnection = true; } // Disable the discovery ping DestoryDiscoverPingTimer(); // We have the IP! Try to connect! m_commandServer = new CommandServer(this, CommandServer.CommmandServerMode.Client, ipAddress); }
/// <summary> /// Called when a server is found! Try to connect. /// </summary> /// <param name="ipAddress"></param> public void OnClientFound(string ipAddress) { lock (objectLock) { // Only let one attempt go through at a time if (m_isPendingConnection || IsConnected) { return; } m_isPendingConnection = true; } // Disable the discovery ping DestoryDiscoverPingTimer(); // We have the IP! Try to connect! m_commandServer = new CommandServer(this, CommandServer.CommmandServerMode.Client, ipAddress); }
/// <summary> /// Fired when a server connection has been lost /// </summary> public void OnDisconnected() { // We disconnected. O no. lock (objectLock) { m_isPendingConnection = false; IsConnected = false; } // Enable the ping timer to attempt to reconnect. CreateDiscoveryPingTimmer(); // Kill the connection m_commandServer = null; if (OnClientDisconnected != null) { OnClientDisconnected(); } }
// The main entry point for glow smarts. public void Run() { // Create the LED controller m_ledController = new LedController(); // Create all of the programs and add them to the cache. IProgram program = new GlowControl(); program.InitProgram(this); m_programCache.Add(GlowPrograms.GlowControl, program); program = new DiscoveryControl(); program.InitProgram(this); m_programCache.Add(GlowPrograms.DiscoveryControl, program); program = new ManualColor(); program.InitProgram(this); m_programCache.Add(GlowPrograms.ManualColors, program); program = new Clock(); program.InitProgram(this); m_programCache.Add(GlowPrograms.Clock, program); program = new Weather(); program.InitProgram(this); m_programCache.Add(GlowPrograms.Weather, program); program = new WeatherCam(); program.InitProgram(this); m_programCache.Add(GlowPrograms.WeatherCam, program); program = new RandomColor(); program.InitProgram(this); m_programCache.Add(GlowPrograms.RandomColor, program); // Create a command listener m_commandServer = new CommandServer(this, CommandServer.CommmandServerMode.Server); // Setup the main worker thread. m_continueWorking = true; m_lastWorkTime = DateTime.Now; m_workerThread = new Task(WorkLoop); m_workerThread.Start(); }