Fraunhofer-IIS / libjapi

libjapi is a universal JSON to C API library. It receives newline-delimited JSON (NDJSON) messages via TCP and calls registered C functions. A JSON response is returned for each request. Furthermore, it is also possible to create push services, which asynchronously push JSON messages to the clients subscribed to them.
MIT License
3 stars 1 forks source link

Provide japi handler that returns application name #39

Open fraunhofer-iis-bot opened 2 years ago

fraunhofer-iis-bot commented 2 years ago

In GitLab by @jannismain on Nov 3, 2021, 11:15

For a generic GUI client, that works with different libjapi-based applications, some identifier is needed (an application name? id? version?) to distinguish those applications as well as inform the user to which application they are currently connected.

This could be combined with #36, so that the command initially sent after connection was established to verify the connection status would return the application id (or name? or both?).

Flow of events would look like something like this

1. client connects to ws://<host>:<port>
        2. libjapi accepts incoming connection
3. client is connected to libjapi-based application (but which one?)
4. client sends request for identification (e.g. {"japi_request": "japi_id"})
        5. libjapi responds with application id (e.g. {"japi_response": "japi_id", "data": {"id": "libjapi-demo"}})
6. client is connected to libjapi-demo and has verified that everything (application, ws connection) is working properly

The data value of the japi_id request could also be extended to include an application id (id), an application name (name) and a version (version) to allow for more granular identification.