summaryrefslogtreecommitdiffstats
path: root/test/AFB.js
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-08-22 09:21:43 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-08-24 19:06:07 +0200
commit99f9504a15ff302c4aa6842ad2f5095263c23c3f (patch)
treedd15323afa61004bcde4537d3a46e316820ef884 /test/AFB.js
parentd7936bbe45900b7bb315e0504672d242b7100af5 (diff)
monitor: Test page for monitoring
This is a test page for showing basic monitoring use. Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'test/AFB.js')
-rw-r--r--test/AFB.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/test/AFB.js b/test/AFB.js
index c77e5e60..88da4d55 100644
--- a/test/AFB.js
+++ b/test/AFB.js
@@ -1,7 +1,16 @@
AFB = function(base, initialtoken){
-var urlws = "ws://"+window.location.host+"/"+base;
-var urlhttp = "http://"+window.location.host+"/"+base;
+if (typeof base != "object")
+ base = { base: base, token: initialtoken };
+
+var initial = {
+ base: base.base || "api",
+ token: base.token || "hello",
+ host: base.host || window.location.host,
+ url: base.url || undefined
+};
+
+var urlws = initial.url || "ws://"+initial.host+"/"+initial.base;
/*********************************************/
/**** ****/
@@ -11,7 +20,7 @@ var urlhttp = "http://"+window.location.host+"/"+base;
var AFB_context;
{
var UUID = undefined;
- var TOKEN = initialtoken;
+ var TOKEN = initial.token;
var context = function(token, uuid) {
this.token = token;
@@ -49,6 +58,7 @@ var AFB_websocket;
u = u + '&x-afb-uuid=' + AFB_context.uuid;
}
this.ws = new WebSocket(u, [ PROTO1 ]);
+ this.url = u;
this.pendings = {};
this.awaitens = {};
this.counter = 0;
@@ -132,6 +142,12 @@ var AFB_websocket;
function close() {
this.ws.close();
+ this.ws.onopen =
+ this.ws.onerror =
+ this.ws.onclose =
+ this.ws.onmessage =
+ this.onopen =
+ this.onabort = function(){};
}
function call(method, request) {