How can I embed uWebSockets in a Qt6 console application so that it does not block the main app? #1900
-
|
I am trying to have uWebSockets server run in a separate dedicated thread in a Qt6 console appplication. It looks like the code execution is always stuck on "app.run();" in my uWebSockets code. A standard Qt application has its own application.exec() which starts the main event loop. My code execution never reaches that point. I have many years of professional software development experience in other languages, but unfortunately I am still a noob in C++. Is there a simple example of how to run a non-blocking uWebSockets app inside another app? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Easy but shitty integration: you put the two incompatible event loops in their own thread (you are going to have problems) Proper integration: you write a Qt6 backend in uSockets and use the Qt event loop for both Qt and uWS (you're not going to manage this) |
Beta Was this translation helpful? Give feedback.
-
|
I was trying to integrate uWebSockets into my applications. Instead, a better idea - for my specific use case - will be to have one central server based on uWebSockets and have all applications subscribe to it using topics: in other words, have a custom message queue server with a bunch of clients. Any custom data processing will be done by dedicated clients which will then communicate the results to those apps which need the results. This kind of modular infrastructure is a PITA to manage, but it's easier to develop. Thank you for your answer. |
Beta Was this translation helpful? Give feedback.
Easy but shitty integration: you put the two incompatible event loops in their own thread (you are going to have problems)
Proper integration: you write a Qt6 backend in uSockets and use the Qt event loop for both Qt and uWS (you're not going to manage this)