looking for some solutions? You are welcome.

SOLVED: Handling multiple clients from QT web server

Vikas G Rao:

I have built an application in c++ QT which has an in built web server running on the embedded platform. On hitting the ip address of the device, the http server gives out a static file to the client to login to system and predefined users can login.

Even the http server is taken care to handle multiple clients and each has it's own thread to provide the static file which in turn loads the html content.

This Webcontent has multiple files to navigate and each html is dynamic loading based on the selection of a dropdown and the data is given from the c++ application, for this I have used web sockets and Qwebchannel methodologies.

Now the issue that is faced is,the user opens multiple session and navigates to a webpage having dynamic content in both. Now in one of the session the user selects the dropdown as "India" for which the data specific to India is retrieved from the DB which C++ is handling and is shown on the page. In other session the user selects "France", this session gets the data specific to France, but the older session which has the data specific to India is updated to France.

In short, whenever backend c++ gets a request from any of the client, it responds to all the clients connected. The request is a Q_INVOKABLE function that is exposed to JS and the reply is a signal to JS with the data in QJson format.

Searched for this extensively in the internet but was unable to find a solution. Is there any way that Q_INVOKABLE function in C++ can know which client is requesting and respond to only that client ?

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: