diff --git a/packages/broker/monitor.webpack.config.js b/packages/broker/monitor.webpack.config.js
new file mode 100644
index 0000000..a38faa9
--- /dev/null
+++ b/packages/broker/monitor.webpack.config.js
@@ -0,0 +1,7 @@
+module.exports = {
+ entry: "./lib/monitor.js",
+ mode: "development",
+ externals: {
+ crypto: 'null'
+ },
+};
diff --git a/packages/broker/src/index.js b/packages/broker/src/index.js
index face8b0..995f787 100644
--- a/packages/broker/src/index.js
+++ b/packages/broker/src/index.js
@@ -14,11 +14,15 @@ import {
const server = Http.HttpServer(null, 8000);
+const fs = require('fs');
+
assertion type ConnectionName(scope, id);
assertion type Connection(connId);
message type Request(connId, body);
message type Response(connId, body);
+message type Disconnect(connId);
+
// Internal isolation
assertion type Envelope(scope, body);
@@ -42,11 +46,24 @@ spawn named 'rootServer' {
assert :snapshot Http.Response(
reqId, 200, "OK", {"Content-type": "text/html"},
'' + UI.htmlToString(
-
+
+
+
+
+
+
+
+
));
}
+
+ during Http.Request($reqId, server, 'get', ['dist', $file], _, _) {
+ const contents = fs.readFileSync(__dirname + '/../dist/' + file);
+ assert :snapshot Http.Response(reqId, 200, "OK", {}, contents);
+ }
+
+ during Connection($name) assert Envelope('monitor', Connection(name));
+ on message Envelope('monitor', Disconnect($name)) send Disconnect(name);
}
spawn named 'websocketListener' {
@@ -59,6 +76,7 @@ spawn named 'websocketListener' {
}
}
on message Response(name, $resp) send Http.DataOut(reqId, new Encoder().push(resp).contents());
+ stop on message Disconnect(name);
}
}
@@ -76,6 +94,7 @@ spawn named 'tcpListener' {
}
}
on message Response(name, $resp) send Tcp.DataOut(id, new Encoder().push(resp).contents());
+ stop on message Disconnect(name);
}
}
diff --git a/packages/broker/src/monitor.js b/packages/broker/src/monitor.js
new file mode 100644
index 0000000..f570b3a
--- /dev/null
+++ b/packages/broker/src/monitor.js
@@ -0,0 +1,46 @@
+"use strict";
+
+const UI = activate require("@syndicate-lang/driver-browser-ui");
+// @jsx UI.html
+// @jsxFrag UI.htmlFragment
+
+const { ToBroker, FromBroker, BrokerConnected } = activate require("./client");
+
+assertion type ConnectionName(scope, id);
+assertion type Connection(connId);
+message type Disconnect(connId);
+
+spawn {
+ const ui = new UI.Anchor();
+ assert ui.html('body',
+ );
+
+ const url = (function () {
+ const u = new URL(document.location);
+ u.protocol = u.protocol.replace(/^http/, 'ws');
+ u.pathname = '/monitor';
+ return u.toString();
+ })();
+
+ during BrokerConnected(url) {
+ during FromBroker(url, Connection(ConnectionName($scope, _))) {
+ const ui = new UI.Anchor();
+ assert ui.html('#scopes',
+ );
+ during FromBroker(url, Connection(ConnectionName(scope, $id))) {
+ const ui = new UI.Anchor();
+ assert ui.html(`#scopes div.scope_${scope} ul`,
+ {id.toString()} );
+ on message UI.UIEvent(ui.fragmentId, 'button.disconnect', 'click', _) {
+ send ToBroker(url, Disconnect(ConnectionName(scope, id)));
+ }
+ }
+ }
+ }
+}