BD - Bidirectional command processor

From LinuxMCE
Jump to: navigation, search

How does it work?

This library allows 2 devices to communicate with each other over sockets or a Bluetooth connection. BD handles the handshaking, communication protocol, and provides a very simple way to send and implement commands.

Both sides are truly peers, and either side sends the other a command by creating an instance of the command. Each side creates an instance of BDCommandProcessor, and then either side can create an instance of a command, add it to BDCommandProcessor, and the other side will implement the command. Each command is really just a simple class derived from BDCommand. You only add whatever member variables you command, and implement a pure virtual "ProcessAction" member function. When one side wants to send that command to the other, it just creates an instance of it, sets member variables, and passes it to the "SendCommand" function in BDCommandProcessor. The framework will automatically serialize the member variables in the class, and send the data to the other side. On the other side, the framework will recreate the class with the member variables set, and call the "ProcessAction" function which you implement to do whatever the command is supposed to do.

Your software doesn't need to worry about any of the data serialization, or the handshaking, or the sending of the commands. The framework handles all that--you just implement the "ProcessAction" function.

Compatibility

This BD library is used by Bluetooth Dongle. It runs on Linux, Windows and Symbian.