Hello List, i’m about to create a new application that communicates via MQTT. For MQTT itself i chose the paho-c library (if you have better alternatives at hand, especially if it’s already GLib “native”, i’m all ears.)
Paho-c doesn’t seem to play well with G(tk)Application, and i read somewhere that it’s generally considered bad design to do the network communication and GUI in the same thread anyway, so i decided to do the MQTT thing in a separate thread. My first question is, where should i instantiate the GThead object? Should it be a separate entity (ie. a global value)? If so, wouldn’t that introduce a problem when i activate an already running instance of my app? Or should i make it a member of my application object? In that case, where should i create the thread? In the constructor or somewhere else? The second question is, how and when should i start this thread? I currently load my settings from GSettings by binding them to my GtkApplicationʼs properties, and load the password from libsecret asynchronously. I guess i should somehow coordinate password loading (only start libsecret operations after GSettings are loaded), and start the MQTT connection only when the password is loaded. Is there a best practice for this? And third, after that is done, i thought i will communicate using a GIO pipe between the MQTT and the GUI threads. Does that sound like a good idea? Is there something better/unwritten standard for this? The other option that came to mind is to send direct “commands” to my some GObjects i create based on the MQTT events flowing in, but iʼm not sure it would bode well between threads. Thanks in advance! Best, Gergely _______________________________________________ gnome-devel-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gnome-devel-list
