I am currently working on establishing bi-directional communication between 2 application (client & server). My objective is that when client calls the server API (i.e FUNCTION fname defined in .api file) , I am also passing a HANDLER (a client function) so that server can respond back to the client by calling the callback from the server side i.e send response back to the client.
Below are my 2 application source file and API file:
string msg IN
string message IN,
callback callbackHandler IN
void Fx(const char* message);
static printer_printClientHandler_t cbkHandler;
void printer_request(const char* message, printer_printClientHandler_t callback, void contextPtr)
LE_INFO("******* Client says ‘%s’", message);
cbkHandler = callback;
cbkHandler(“How are you client”);
void Fx(const char* message)
LE_INFO("******** Internal message: ‘%s’", message);
static void internal_fn(const char *message);
LE_INFO(“Asking server to print ‘Hello, world!’”);
void callback(const char *rsp)
LE_INFO(“Response received from server: ‘%s’”, rsp);
void internal_fn(const char *message)
LE_INFO(“Calling server API from internal fn!!!”);
printer_request(message, callback, NULL);
LE_INFO(“Response received from server: ‘%s’!!!”, response);
I am observing the crash at the server side when the callback function is getting called saying the address is ‘null’.
Is this approach the correct approach for communication between 2 seperate legato applications each having one component each. If not please provide correct approach with some source code.
Thanks and regards,