Connection count |
|
diff --git a/web/index.js b/web/index.js
index 58d9201..4865b5c 100644
--- a/web/index.js
+++ b/web/index.js
@@ -1,6 +1,4 @@
function server_disconnected() {
- $("#server_ok")[0].className = "btn-danger";
- $("#server_ok").text("Disconnected");
$("#server_stats_connection_count").text("—");
$("#server_stats_boot_time").text("—");
$("#server_stats_uptime").text("—");
@@ -9,8 +7,6 @@ function server_disconnected() {
function refresh_server_stats() {
$.getJSON("/_/server_stats", function (data) {
- $("#server_ok")[0].className = "btn-success";
- $("#server_ok").text("OK");
$("#server_stats_connection_count").text(data.connection_count);
$("#server_stats_boot_time").text(new Date(data.boot_time * 1000));
$("#server_stats_uptime").text(data.uptime);
@@ -30,17 +26,17 @@ function ui_main() {
refresh_server_stats();
setInterval(refresh_server_stats, 5000);
+ Ocamlmsg.$open_hooks.push(function (event, stream) {
+ refresh_server_stats();
+ Ocamlmsg.post(stream.id, {"test":true});
+ Ocamlmsg.create("fanout", ["system.log"], "completion1");
+ Ocamlmsg.subscribe("meta", "system.log", "sub_messages", "completion2");
+ Ocamlmsg.subscribe("system.log", "", "log_messages", "completion3");
+ });
+ Ocamlmsg.$close_hooks.push(server_disconnected);
Ocamlmsg.install_tap({
- open: function (event, stream) {
- refresh_server_stats();
- Ocamlmsg.post(stream.id, {"test":true});
- Ocamlmsg.create("fanout", ["system.log"], "completion1");
- Ocamlmsg.subscribe("meta", "system.log", "sub_messages", "completion2");
- Ocamlmsg.subscribe("system.log", "", "log_messages", "completion3");
- },
message: function (event, stream) {
$("#debug_container").append(JSON.stringify(event.data) + "\n");
},
- close: server_disconnected
});
}
diff --git a/web/nodes.html b/web/nodes.html
index c7c37ee..63d53fb 100644
--- a/web/nodes.html
+++ b/web/nodes.html
@@ -10,18 +10,21 @@
}
-
Nodes
diff --git a/web/ocamlmsg.js b/web/ocamlmsg.js
index 6c6fa4f..ab2dbe0 100644
--- a/web/ocamlmsg.js
+++ b/web/ocamlmsg.js
@@ -2,6 +2,17 @@ var Ocamlmsg = {
$tap: null,
$args: null,
+ $open_hooks: [],
+ $close_hooks: [],
+
+ run_open_hooks: function (event, stream) {
+ $.each(Ocamlmsg.$open_hooks, function (i, f) { f(event, stream); });
+ },
+
+ run_close_hooks: function (event, stream) {
+ $.each(Ocamlmsg.$close_hooks, function (i, f) { f(event, stream); });
+ },
+
_send: function (msg) {
Ocamlmsg.$tap.send({data: JSON.stringify(msg)});
},
@@ -63,10 +74,10 @@ var Ocamlmsg = {
dataType: "json",
enableXDR: true,
- open: args.open,
+ open: Ocamlmsg.run_open_hooks,
message: args.message,
- error: args.close,
- close: args.close
+ error: Ocamlmsg.run_close_hooks,
+ close: Ocamlmsg.run_close_hooks
});
},