When a client (web browser) connects to the server, a new application instance is created and a session ID is affected to it. All further communication between the client and the server use this session ID, refering always the same application instance within the server.
Each application instance is independant of the others. Modifying the widgets won't affect the other application instances.
You can chose between two different ways of handling client requests:
If the application cannot provide any html code for the given URL, the request is forwarded to a file ressource provider who will check if a file on the disk corresponds to the request and than will transmit it.
QtWui makes use of the AJAX technology to communicate between the client and the server. All the client AJAX machinery is provided by Prototype Javascript Framework (http://www.prototypejs.org/).
// // the traditionnal main function only starts the application server. // int main(int argc, char** argv) { QCoreApplication app(argc, argv); QwuiApplicationServer webAppServer(webMain); webAppServer.setBuiltInServerPort(8888); webAppServer.exec(); return app.exec(); } // // This is the main function executed by the application server for each new session. // QwuiApplication* webMain(const QString& sessionId, const QStringList& args) { Q_UNUSED(args); QwuiApplication* webApp = new QwuiApplication(sessionId); QwuiMainWebget* mw = new QwuiMainWebget(NULL, "mw"); mw->setTitle("QtWui Test"); QwuiLabel* helloWorld = new QwuiLabel(mw, "helloWorld"); webApp->setMainWebget(helloWorld); helloWorld->setText("Hello World !"); return webApp; }
qmake make ./run_hangman.sh
qmake nmake run_hangman.bat
The run_hangman script starts the server on the port 8888. edit the script to change the port. Then start a web browser and go to the http://localhost:8888 page to try the game.
Help is welcome! To get in touch with me: eric DOT alber AT gmail DOT com