We will create the following two classes:
- Vehicle: This class will represent a vehicle and provide methods that will be called whenever a command has to be processed. In order to keep the example simple, our methods will just print the actions that the vehicle executes after each method is called to the console output. A real-life class that represents a vehicle would interact with the engine, the lights, the actuators, the sensors, and the other different components of the vehicle whenever each method is called.
- VehicleCommandProcessor: This class will represent a command processor that will establish a connection with an MQTT server, subscribe to a topic in which the MQTT client will receive messages with commands, analyze the incoming messages, and delegate the execution of the commands to an associated instance of the Vehicle class...