// Send a command asynchronously, and perform the appropriate callback when a response is received,
 // or the request times out.
 public void SendCommandAsync(Command command, OnResponseReceived OnReceived, OnResponseTimeout OnTimeout, TimeSpan timeout)
 {
     connection.SendMessage(
         0,
         command.ID,
         "",
         (string answer) => {
         OnReceived(new List <string>(answer.Split('\n')));
     },
         () => {
         OnTimeout();
     },
         timeout
         );
 }
        // Get available commands asynchronously, and perform the appropriate callback when a response is received,
        // or the request times out.
        public void GetEnabledCommandsAsync(OnCommandListReceived OnReceived, OnResponseTimeout OnTimeout, TimeSpan timeout)
        {
            if (AreCommandsOutdated)
            {
                SendCommandAsync(
                    ListCommandsCommand,
                    (List <string> response) => {
                    commands            = DecodeCommands(response);
                    AreCommandsOutdated = false;

                    OnReceived(commands);
                },
                    OnTimeout,
                    timeout
                    );
            }
            else
            {
                OnReceived(commands);
            }
        }