Report WebSocketConnection crashes to user
This commit is contained in:
parent
03ec966a02
commit
58ed6377d4
12
index.js
12
index.js
|
@ -351,18 +351,16 @@ $(document).ready(function () {
|
||||||
World.spawn(wsconn);
|
World.spawn(wsconn);
|
||||||
World.spawn({
|
World.spawn({
|
||||||
// Monitor connection, notifying connectivity changes
|
// Monitor connection, notifying connectivity changes
|
||||||
state: null,
|
state: "crashed", // start with this to avoid spurious initial message print
|
||||||
boot: function () {
|
boot: function () {
|
||||||
World.updateRoutes([sub(["broker_state", __], 0, 1)]);
|
World.updateRoutes([sub(["broker_state", __], 0, 1)]);
|
||||||
},
|
},
|
||||||
handleEvent: function (e) {
|
handleEvent: function (e) {
|
||||||
if (e.type === "routes") {
|
if (e.type === "routes") {
|
||||||
if (e.routes.length > 0) {
|
var newState = (e.routes.length > 0) ? e.routes[0].pattern[1] : "crashed";
|
||||||
var newState = e.routes[0].pattern[1];
|
if (this.state != newState) {
|
||||||
if (this.state != newState) {
|
outputState(newState);
|
||||||
outputState(newState);
|
this.state = newState;
|
||||||
this.state = newState;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,15 @@ span.state.disconnected, span.departed {
|
||||||
color: #c00000;
|
color: #c00000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.state.crashed {
|
||||||
|
color: white;
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.state.crashed:after {
|
||||||
|
content: "; please reload the page";
|
||||||
|
}
|
||||||
|
|
||||||
div.state_disconnected {
|
div.state_disconnected {
|
||||||
background-color: #ffeeee;
|
background-color: #ffeeee;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue