I am trying to handle network reconnection, but I seem to be having a problem with the relevant events (onNetworkRestored, onNetworkConnectionReconnect, onNetworkHideDialog) not firing. I've created event handlers for them with the following code in my init.js:
CODE
EventHandlers.onNetworkRestored.subscribeTo(KONtx.application, ['onNetworkRestored','onNetworkConnectionReconnect'], EventHandlers);
EventHandlers.onNetworkHideDialog.subscribeTo(KONtx.application, ['onNetworkHideDialog'], EventHandlers);
For testing, I have just added logging to the event handlers:
CODE
onNetworkRestored: function(event) {
log("NETWORK RESTORED");
}
onNetworkHideDialog: function(event) {
log("NETWORK HIDE DIALOG");
}
I then follow this process:
- With TV/Simulator off, Disconnect network
- Turn on TV/Simulator
- Start widget sidebar - this shows "Connection Unavailable"
- Close widget sidebar
- Reconnect network
- Start widget - Still get "Connection Unavailable"
At this point, I go check the logs, and I am unable to find my log output. Then I try this procedure (restarting the simulator):
- Turn on TV/simulator
- Start widget sidebar
- Close widget sidebar
- Disconnect network (leaving TV on)
- Start widget sidebar - note "Connection Unavailable"
- Close widget sidebar
- Reconnect network
- Start widget sidebar - widget loads as expected
In this case, when I check the logs, I DO find the log output.
Based on this, it seems to me that in the first instance, the events aren't firing. So how can I respond to the network reconnection?