And now we are starting to implement the new message responder on Proxy Level.
First candidate is the template and we start with the hardware detection.
Steps:
- Derive driver from Subscriber
- Convert the Driver::HardwareDetection
- Add responder in main
- Update the ProxyDriver
Proxy: Derive driver from subscriber
Add #include "../Libraries/TCP/Subscriber.h"
Derive Driver from public CTrack::Subscriber
Proxy: Convert driver function
CTrack::Reply Driver::HardwareDetect(const CTrack::Message &message)
{
CTrack::Reply Return = std::make_unique<CTrack::Message>(TAG_COMMAND_HARDWAREDETECT);
.....
Return->GetParams()[ATTRIB_HARDWAREDETECT_PRESENT] = Present;
....
return Return;
}
The original handlers are XML based and need to be converted into JSON as shown above.
Proxy: Add driver responder
driver->Subscribe(*TCPServer.GetMessageResponder(),TAG_COMMAND_HARDWAREDETECT, CTrack::MakeMemberHandler(driver.get(), &Driver::HardwareDetect));
The driver registers its HardwareDetect function as a responder to the message TAG_COMMAND_HARDWAREDETECT in TCPServer.
The registration is done in the main.cpp before entering the big loop.
Engine: Update proxydriver
Based on the Handshake we can add new base functions to CProxyDevice: