Monday, 20 July 2020

Socket.io communication between native android app and an electron desktop app

I made an electron desktop app that allows me to monitor my PC stats (such as CPU usage, memory usage etc). It uses a nodejs module to collect these stats and I am using a setInterval function that reads my PC stats every 2 seconds and emits the data via socket.io to the node.js backend. My goal is to remotely monitor those stats on an android app that I am making using android studio and java. I already successfully established a connection between my desktop app and my node.js backend using socket.io. However, I am not sure where to go from here.My understanding is that socket.io only allows communication between one type of app and the server (like the electron app and my node.js backend), not among several different apps (like an android app, electron app and the server) and I have to establish a separate connection between my android app and the server. Is my understanding correct? In that case what would be the next logical step?I want the electron app to only emit data when my android app switches to the monitor screen, and allow my android app to monitor the data in real-time. How I do that? I am extremely stuck at this stage. Should I use a database to store the monitoring data and emit them to the android app? Or should I have a variable that when my android app switches to the monitoring screen, it emits an event which in turn sets a flag in my nodejs backend to be true which in turn notifies the electron app to start emitting data? Or something else?Thanks

Submitted July 20, 2020 at 08:05AM by sinus_lebastian

No comments:

Post a Comment