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;
/*********************************************/
/**** ****/
var AFB_context;
{
var UUID = undefined;
- var TOKEN = initialtoken;
+ var TOKEN = initial.token;
var context = function(token, uuid) {
this.token = token;
u = u + '&x-afb-uuid=' + AFB_context.uuid;
}
this.ws = new WebSocket(u, [ PROTO1 ]);
+ this.url = u;
this.pendings = {};
this.awaitens = {};
this.counter = 0;
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) {