setForeground

fun setForeground(foreground: Boolean)

The app moved to the foreground or background. In the background the gateway is told at once (app.state) and the socket closes after backgroundCloseDelay; back in the foreground it reconnects.