/// <summary>
        /// Handles a command from the server.
        /// </summary>
        private async Task HandleCommand(ScheduledCommand command)
        {
            // Update the server state of the command
            command.State = CommandState.InProgress;
            await UpdateCommand(command);

            switch (command.Name)
            {
            case "arm":
                await ServerCommandRecieved.Invoke(command);

                break;

            case "disarm":
                await ServerCommandRecieved.Invoke(command);

                break;

            case "alarm":
                await ServerCommandRecieved.Invoke(command);

                break;

            case "silence":
                await ServerCommandRecieved.Invoke(command);

                break;

            case "clientDelete":
                command.State  = CommandState.Complete;
                command.Result = CommandResult.Success;
                await UpdateCommand(command);
                await Unenroll();

                break;

            default:
                // Command is invalid.
                command.State  = CommandState.Complete;
                command.Result = CommandResult.Invalid;
                await UpdateCommand(command);

                break;
            }
        }
 /// <summary>
 /// Recieves a command.
 /// </summary>
 public void RecieveCommand()
 {
     new Task(() =>
     {
         try
         {
             while (connected)
             {
                 NetworkStream stream = client.GetStream();
                 BinaryReader reader  = new BinaryReader(stream);
                 string commandRead   = reader.ReadString();
                 //Console.WriteLine("Recieved from server:\n" + commandRead);
                 CommandRecievedEventArgs command = JsonConvert.DeserializeObject <CommandRecievedEventArgs>(commandRead);
                 ServerCommandRecieved?.Invoke(command);
             }
         }
         catch (Exception exception)
         {
             //Console.WriteLine(exception.ToString());
         }
     }).Start();
 }