public void Stop(string args)
 {
     if (monitor == null)
     {
         CrestronConsole.ConsoleCommandResponse("Monitor already stopped\r\n");
         return;
     }
     monitor.Unsubscribe(); // sends a DELETE request to the server so it no longer will notify the monitor's listener URL
     monitor.Dispose();
     monitor = null;
     CrestronConsole.ConsoleCommandResponse("Monitor has been stopped\r\n");
 }
        // Monitor a random relay on the server control system.
        // This monitor can only subscribe to one relay at a time
        public void Monitor(string serverHostname)
        {
            try
            {
                if (monitor != null)
                {
                    CrestronConsole.ConsoleCommandResponse("Already subscribed: " + monitor + "\r\n");
                    return;
                }
                string myHostname = "";
                // adapterID 0 usually represents the outbound LAN port
                myHostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0).ToLower();

                monitor = new RelayMonitor(myHostname);
                monitor.Subscribe(serverHostname);

                CrestronConsole.ConsoleCommandResponse("Now monitoring: " + monitor);
            }
            catch (Exception e)
            {
                if (monitor != null)
                {
                    monitor.Dispose();
                    monitor = null;
                }
                CrestronConsole.ConsoleCommandResponse("Could not start client: {0}\r\n", e.Message);
            }
            finally
            {
            }
        }