From e36f8d572ca660f5c06fe45297d13c7a6818cc65 Mon Sep 17 00:00:00 2001 From: Jose Bollo Date: Mon, 20 Aug 2018 17:45:42 +0200 Subject: 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 --- test/monitoring/AFB.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'test/monitoring') 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(); -- cgit 1.2.3-korg