summaryrefslogtreecommitdiffstats
path: root/test/monitoring/AFB.js
diff options
context:
space:
mode:
authorJose Bollo <jose.bollo@iot.bzh>2018-08-20 17:45:42 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-08-23 08:35:38 +0200
commite36f8d572ca660f5c06fe45297d13c7a6818cc65 (patch)
tree51cf8b93d3d7a636d2f6fbab8057f10ee0f3ef0d /test/monitoring/AFB.js
parenta1a507793efff92b35603e4948e9f6dff4fba99c (diff)
Send error replies on disconnection
The pending calls receive an error notification when the server hang up. Bug-AGL: SPEC-1668 Change-Id: I052dca5e338a7650d7630856e21f1d3a81c6f265 Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'test/monitoring/AFB.js')
-rw-r--r--test/monitoring/AFB.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/monitoring/AFB.js b/test/monitoring/AFB.js
index 8fccdb04..aa634168 100644
--- a/test/monitoring/AFB.js
+++ b/test/monitoring/AFB.js
@@ -67,12 +67,13 @@ var AFB_websocket;
var PROTO1 = "x-afb-ws-json1";
AFB_websocket = function(on_open, on_abort) {
- var u = urlws;
+ var u = urlws, p = '?';
if (AFB_context.token) {
u = u + '?x-afb-token=' + AFB_context.token;
- if (AFB_context.uuid)
- u = u + '&x-afb-uuid=' + AFB_context.uuid;
+ p = '&';
}
+ if (AFB_context.uuid)
+ u = u + p + 'x-afb-uuid=' + AFB_context.uuid;
this.ws = new WebSocket(u, [ PROTO1 ]);
this.url = u;
this.pendings = {};
@@ -104,8 +105,15 @@ var AFB_websocket;
}
function onclose(event) {
+ var err = {
+ jtype: 'afb-reply',
+ request: {
+ status: 'disconnected',
+ info: 'server hung up'
+ }
+ };
for (var id in this.pendings) {
- try { this.pendings[id][1](); } catch (x) {/*TODO?*/}
+ try { this.pendings[id][1](err); } catch (x) {/*NOTHING*/}
}
this.pendings = {};
this.onclose && this.onclose();