Fix #486, handle connection status properly when recover from sleep

In this change, when beaker get a disconnect change (from cometd), it
will wait for 5 seconds. If within 5 seconds, there is a connect event,
it will try to ditinguish the connect event coming from a valid
reconnect(same session is still availble) from an invalid connect that
can for example come from server crash or user stopping the server
intentionally. If there is no connect event, again within 5 sec of
the disconnect event, and there is a key press event, as well as timeout
after 5 secs, beaker will treat the situation as server is permanently
gone and stop further reconnect attempt and pops up the dialog for
saving the notebook model as a client file (#353)