From: José Bollo Date: Thu, 14 Apr 2016 11:05:56 +0000 (+0200) Subject: only one context X-Git-Tag: blowfish_2.0.1~190 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fapp-framework-binder.git;a=commitdiff_plain;h=d3a68744e728b77d2c37f51e865f2f49e533b6f7 only one context Change-Id: Idd27b7d5a1ecd1925d4777e2d311110590f45a5e Signed-off-by: José Bollo --- diff --git a/src/afb-api-so.c b/src/afb-api-so.c index 32d097fa..2616e0bc 100644 --- a/src/afb-api-so.c +++ b/src/afb-api-so.c @@ -1,6 +1,5 @@ /* * Copyright (C) 2016 "IoT.bzh" - * Author "Fulup Ar Foll" * Author José Bollo * * This program is free software: you can redistribute it and/or modify diff --git a/test/AFB.js b/test/AFB.js index d0febcd6..309db472 100644 --- a/test/AFB.js +++ b/test/AFB.js @@ -13,17 +13,19 @@ var AFB_context; var UUID = undefined; var TOKEN = initialtoken; - AFB_context = function(token, uuid) { + var context = function(token, uuid) { this.token = token; this.uuid = uuid; } - AFB_context.prototype = { + context.prototype = { get token() {return TOKEN;}, set token(tok) {if(tok) TOKEN=tok;}, get uuid() {return UUID;}, set uuid(id) {if(id) UUID=id;} }; + + AFB_context = new context(); } /*********************************************/ /**** ****/ @@ -38,11 +40,10 @@ var AFB_websocket; var PROTO1 = "x-afb-ws-json1"; - AFB_websocket = function(onopen, onabort, ctx) { + AFB_websocket = function(onopen, onabort) { this.ws = new WebSocket(urlws, [ PROTO1 ]); this.pendings = {}; this.counter = 0; - this.ctx = ctx || new AFB_context(); this.ws.onopen = onopen.bind(this); this.ws.onerror = onerror.bind(this); this.ws.onclose = onclose.bind(this); @@ -82,7 +83,7 @@ var AFB_websocket; var code = obj[0]; var id = obj[1]; var ans = obj[2]; - this.ctx.token = obj[3]; + AFB_context.token = obj[3]; var pend; if (id && id in this.pendings) { pend = this.pendings[id]; @@ -107,7 +108,7 @@ var AFB_websocket; var id = String(++this.counter); this.pendings[id] = { onsuccess: onsuccess, onerror: onerror }; var arr = [CALL, id, api+"/"+verb, request ]; - if (this.ctx.token) arr.push(this.ctx.token); + if (AFB_context.token) arr.push(AFB_context.token); this.ws.send(JSON.stringify(arr)); }