Client lost values when reloading the page on a slow connection

In my last show, at some point, the browser on the tablet barfed and I had to reload the page. After that, all the faders reverted to 0. It took a little time to reset the display.

Investigating just now, I found that the faders restore their values upon reload if I'm using a fast-enough local network, but they don't over a slow network. For that show, I hadn't bothered to bring a dedicated wifi router because I had found that Bluetooth network tethering worked reasonably well. (At least, I hadn't encountered this problem until that one night onstage.) The Bluetooth network is slow to transmit the page, but interacts fine after that.

I guess that the server might have a hardcoded delay before retransmitting fader values -- is there a way to slow them down?

Or -- I also found this -- Keeping the session alive - #3 by Ant1r --

Ok, I ended up with a simple:

app.on('sessionOpened', (data, client)=>{
    send('localhost', 18080, '/client_connected')
})

Now my (Pd) app can refresh all states when it receives /client_connected. So this answers my needs, thanks!

In some ways, this would be better, because I could also resync button labels.

BUT I'm an idiot and I don't know where to put this JS signal handler -- can anyone point me in the right direction?

Thanks,
hjh

OK, got it... just write into a .js file and set the server option custom-module.

The custom-module help page doesn't really make it clear... 'module.exports', OK, but app.xxx things are outside of that.

hjh