Report WebSocketConnection crashes to user

This commit is contained in:
Tony Garnock-Jones 2013-11-03 15:56:50 -05:00
parent 03ec966a02
commit 58ed6377d4
2 changed files with 14 additions and 7 deletions

View File

@ -351,18 +351,16 @@ $(document).ready(function () {
World.spawn(wsconn);
World.spawn({
// Monitor connection, notifying connectivity changes
state: null,
state: "crashed", // start with this to avoid spurious initial message print
boot: function () {
World.updateRoutes([sub(["broker_state", __], 0, 1)]);
},
handleEvent: function (e) {
if (e.type === "routes") {
if (e.routes.length > 0) {
var newState = e.routes[0].pattern[1];
if (this.state != newState) {
outputState(newState);
this.state = newState;
}
var newState = (e.routes.length > 0) ? e.routes[0].pattern[1] : "crashed";
if (this.state != newState) {
outputState(newState);
this.state = newState;
}
}
}

View File

@ -30,6 +30,15 @@ span.state.disconnected, span.departed {
color: #c00000;
}
span.state.crashed {
color: white;
background: red;
}
span.state.crashed:after {
content: "; please reload the page";
}
div.state_disconnected {
background-color: #ffeeee;
}