Initial contribution

First four scripts allowing to connect to a sensiNact gateway instance : the Gateway itself, defining the configuration attached to the remote instance to be connected to; the Transmitter, in charge of transmitting a request and receiving its response; the Runner, in charge of managing the set of requests and responses; and finally the Authentication, permitting to handle the authentication material
diff --git a/script/Authentication.js b/script/Authentication.js
new file mode 100644
index 0000000..b30872e
--- /dev/null
+++ b/script/Authentication.js
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2017 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    CEA - initial API and implementation
+ */
+var Base64 = (function(){
+	
+	function Base64()
+	{
+		this.codes = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
+			'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h',
+			'i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
+			'0','1','2','3','4','5','6','7','8','9','+','/'];
+	}
+	
+	Base64.prototype.encode = function(s)
+	{
+		var l = s.length;
+		var pos = 0;
+		var count = 0;
+		var sum = 0;
+	
+		var intermediate = 0x000000;	
+		var result = "";	
+	
+		while(pos < l)
+		{
+			var charcode = s.charCodeAt(pos);
+			
+			count=(charcode < 0x100)?8:16;
+			intermediate <<= count;
+			intermediate |= charcode;
+			
+			sum+=count;
+			pos++;
+			
+			if(sum == 24 | pos == l)
+			{	
+				while(sum % 6 != 0)
+				{
+					intermediate <<= 1;
+					sum++;
+				}			
+				var offset = sum/6;
+				for(var  i= offset; i > 0 ; i--)
+				{
+					result += this.codes[((intermediate >>> (6*(i-1))) & 0x00003F)];				
+				}			
+				while(sum < 24)
+				{
+					sum+=6;
+					result+='=';
+				}
+				sum = 0;
+				intermediate = 0x000000;
+			}
+		}
+		return result;
+	};
+
+	Base64.prototype.decode = function(s)
+	{
+		var aUpperCode = 'A'.charCodeAt(0);
+		var zUpperCode = 'Z'.charCodeAt(0);
+		var aLowerCode = 'a'.charCodeAt(0);
+		var zLowerCode = 'z'.charCodeAt(0);
+		var zeroCode = '0'.charCodeAt(0);
+		var nineCode = '9'.charCodeAt(0);
+	
+		var l = s.length;
+		var pos = 0;
+		var count = 0;
+		var sum = 0;
+	
+		var intermediate = 0x000000;	
+		var result = "";	
+	
+		while(pos < l)
+		{
+			var ch = s.charAt(pos);
+			var charcode = ch.charCodeAt(0);
+			var index = -1;
+			
+			switch(ch)
+			{
+				case '=': index = -1;
+				break;
+				case '+': index = 62;
+				break;
+				case '/': index = 63;
+				break;
+				default:
+					if(charcode >= aUpperCode && charcode <= zUpperCode)
+					{
+						index = (charcode - aUpperCode);
+						
+					} else if(charcode >= aLowerCode && charcode <= zLowerCode)
+				    {
+						index = (charcode - aLowerCode) + 26;
+						
+				    } else if(charcode >= zeroCode && charcode <= nineCode)
+				    {
+				    	index = (charcode - zeroCode) + 52
+				    }
+			}		
+			if(index > -1)
+			{
+				intermediate <<= 6;
+				intermediate |= index;
+				sum+=6;
+			}
+			pos++;
+			
+			if(sum == 24 | pos == l)
+			{	
+				while(sum % 8 != 0)
+				{
+					intermediate >>>= 1;
+					sum--;
+				}			
+				var offset = sum/8;
+				for(var  i= offset; i > 0 ; i--)
+				{
+					result += String.fromCharCode(
+						(intermediate >>> (8*(i-1))) & 0x0000FF);
+				}
+				sum = 0;
+				intermediate = 0x000000;
+			}
+		}
+		return result;
+	};
+	
+	return Base64;
+}());
+
+var Authentication = (function(){
+	
+	function Authentication()
+	{
+		this.headerKey = null;
+		this.headerValue = null;		
+	};
+	
+	Authentication.prototype.getHeaderKey = function()
+	{
+		return this.headerKey;
+	};
+	
+	Authentication.prototype.getHeaderValue = function()
+	{
+		return this.headerValue;
+	};
+	
+	return Authentication;
+	
+}());
+
+var Credentials = (function(login, password){
+	
+	function Credentials(login, password)
+	{
+		Authentication.call(this);
+		this.headerKey = "Authorization";
+		this.headerValue = "Basic " + new Base64().encode(login+":"+password);
+	};
+	
+	return Credentials;
+
+}());
+
+Credentials.prototype = Object.create(Authentication.prototype);
+
+var Token = (function(token){
+	
+	function Token(token)
+	{
+		Authentication.call(this);
+		this.headerKey = "X-Auth-Token";
+		this.headerValue = token;
+	};
+	
+	return Token;	
+}());
+
+Token.prototype = Object.create(Authentication.prototype);
diff --git a/script/Gateway.js b/script/Gateway.js
new file mode 100644
index 0000000..9a1817b
--- /dev/null
+++ b/script/Gateway.js
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2017 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    CEA - initial API and implementation
+ */
+var Gateway = (function () {
+	
+	var RequestIDGenerator = (function(){
+		
+		function RequestIDGenerator()
+		{}
+		
+		RequestIDGenerator.prototype.nextID = function()
+		{
+			var now = (new Date).getTime();
+			now+= Math.floor(Math.random()*10000000);
+			return "req"+now;			
+		}
+		
+		return RequestIDGenerator;
+	}());
+	
+    function Gateway(host, port, timeout) 
+    {    	
+    	this.authentication = null;
+        this.connected = false;
+        this.runners = [];
+        this.host = host;
+        this.port = port;
+        this.timeout = timeout;
+        this.sid = undefined;
+        this.sidLoc = undefined;
+        this.generator = new RequestIDGenerator();
+    }
+    
+    Gateway.prototype.errorConnection = function (obj, errStr) {
+    };
+    
+    Gateway.prototype.isConnected = function () {
+        return this.connected;
+    };
+    
+    Gateway.prototype.getHost = function () {
+        return this.host;
+    };
+    
+    Gateway.prototype.setHost = function (host) {
+        this.host = host;
+    };
+    
+    Gateway.prototype.getPort = function () {
+        return this.port;
+    };
+    
+    Gateway.prototype.setPort = function (port) {
+        this.port = port;
+    };
+    
+    Gateway.prototype.getTimeout = function () {
+        return this.timeout;
+    };
+    
+    Gateway.prototype.setTimeout = function (timeout) {1
+        this.timeout = timeout;
+    };
+    
+    Gateway.prototype.getConnectionTime = function () {
+        return this.connectionTime;
+    };
+    
+    Gateway.prototype.getRefreshTime = function () {
+        return this.refreshTime;
+    };
+
+    Gateway.prototype.getHttpURL = function()
+    {
+    	var url = "http://" + this.host + ":" + this.port ;
+    	return url;
+    };
+    
+    Gateway.prototype.getWebSocketURL = function()
+    {
+    	var url = "ws://" + this.host + ":" + this.port + "/ws";
+    	return url;
+    }; 
+    
+    Gateway.prototype.formatURL = function(segments, method, http) 
+    {
+    	var url=(http != null && http)?this.getHttpURL():this.getWebSocketURL(); 
+    	url += this.path(segments);
+
+        if(method !== undefined)
+    	{
+    		url += "/" + method;
+    	}
+        return url;
+    };
+
+    Gateway.prototype.connect = function(agentCallback, agentClosing)
+    {
+    	this.connected = true;
+    	this.runners.push(new Runner(new HttpTransmitter(this, 
+    		this.formatURL([], undefined, true))));
+    	
+    	this.runners[0].start();
+    	
+    	this.runners.push(new Runner(new WebSocketTransmitter(this,
+    		this.formatURL(["sensinact"], undefined, false)))); 
+    	
+    	this.runners[1].start();      
+
+    	var c = agentCallback==null?function(f){console.log(f)}:agentCallback;
+    	this.runners[1].setMapping("DEFAULT", c, null, false);
+    	
+		this.request("POST",["sensinact","SUBSCRIBE"],
+	    "[{\"name\":\"sender\",\"type\":\"string\",\"value\":\"/[^/]+/admin/location(/[^/]+)?\"},"+
+		"{\"name\":\"pattern\",\"type\":\"boolean\",\"value\":true},"+
+		"{\"name\":\"complement\",\"type\":\"boolean\",\"value\":false}," +
+		"{\"name\":\"types\",\"type\":\"array\",\"value\":[\"UPDATE\"]}]",
+		[], function(e)
+    	{
+    		var json = JSON.parse(e);    		
+    		if(json.type === "SUBSCRIBE_RESPONSE")
+    		{
+    			this.sidLoc = json.response.subscriptionId;
+    		} 		
+    	}.bind(this), function(e){console.error(e);}, true);
+
+		this.request("POST",["sensinact","SUBSCRIBE"],
+		"[{\"name\":\"sender\",\"type\":\"string\",\"value\":\"(/[^/]+)+\"}," +
+		"{\"name\":\"pattern\",\"type\":\"boolean\",\"value\":true}," +
+		"{\"name\":\"complement\",\"type\":\"boolean\",\"value\":false}," +
+		"{\"name\":\"types\",\"type\":\"array\",\"value\":[\"LIFECYCLE\"]}]",
+		[], function(e)
+    	{
+    		var json = JSON.parse(e);    		
+    		if(json.type === "SUBSCRIBE_RESPONSE")
+    		{
+    			this.sid = json.response.subscriptionId;
+    			(this.runners[1].getMapping("DEFAULT").getCallback())(null);
+    		}   		
+    	}.bind(this), function(e){console.error(e);}, true);
+    }
+    
+    Gateway.prototype.path = function(segments) 
+    {
+    	var path="";    	
+    	var length = segments==null?0:segments.length;
+    	
+        for (var i = 0; i < length; i++) 
+        {
+            path+= "/" + segments[i];
+        }
+        return path;
+    };
+
+    Gateway.prototype.disconnect = function () 
+    {
+    	this.connected = false;
+    	this.runners[1].removeMapping("DEFAULT");
+    	
+    	if(this.sid != null)
+    	{
+    		this.request("POST",["sensinact","UNSUBSCRIBE"],
+    		"[{\"name\":\"subscriptionId\",\"type\":\"string\",\"value\":\""+
+    		this.sid+"\"}]", [], null, null, true);
+    	}
+    	if(this.sidLoc != null)
+    	{
+    		this.request("POST",["sensinact","UNSUBSCRIBE"],
+    	    "[{\"name\":\"subscriptionId\",\"type\":\"string\",\"value\":\""+
+    	    this.sidLoc+"\"}]", [], null, null, true);
+    	}
+    	this.runners[0].stop();
+    	this.runners[0] = null;
+    	
+    	this.runners[1].stop();
+    	this.runners[1] = null;
+    	
+        this.connectionTime = null;
+        this.refreshTime = null;
+    }; 
+
+    Gateway.prototype.request = function (
+    	method, segments, parameters, headers, callback, 
+    	errorCallback, once) 
+    {
+    	var m = (segments!=null && segments.length > 0)
+    	?segments[segments.length -1]:null;
+    	
+    	if(m==null)
+    	{
+    		console.error("invalid request path");
+    		return;
+    	}    
+    	var content = null;
+    	var strContent = null;
+    	
+    	if (typeof parameters === 'string' || parameters instanceof String)
+    	{
+    		strContent = parameters;
+    		content = JSON.parse(parameters);
+    		
+    	} else
+    	{
+    		content = parameters;
+    		strContent = JSON.stringify(parameters);
+    	}	
+    	var runner = (m==="SUBSCRIBE"|| m==="UNSUBSCRIBE")
+    	?this.runners[1]:this.runners[0];
+    	
+    	if(m === "UNSUBSCRIBE")
+    	{  
+    		runner.removeMapping(content[0].value);
+    	}
+    	runner.push(this.generator.nextID(), method, 
+    		this.path(segments), strContent, headers, 
+    		callback, errorCallback, once);
+    };
+
+	Gateway.prototype.setAuthentication = function(a)
+	{ 
+		if(a instanceof Authentication)
+		{
+			this.authentication = a;
+		}
+	};
+
+	Gateway.prototype.getAuthentication = function()
+	{ 
+		return this.authentication;
+	};
+	
+    return Gateway;
+	}());
+
+var Gateways = (function () {
+    function Gateways() {
+        this.dict = {};
+    }
+    return Gateways;
+}());
+
+var GatewaysSingleton = (function () {
+    function GatewaysSingleton() {
+    }
+    GatewaysSingleton.get = function () {
+        if (!this.instance) {
+            this.instance = new Gateways();
+        }
+        return this.instance;
+    };
+    return GatewaysSingleton;
+}());
\ No newline at end of file
diff --git a/script/Runner.js b/script/Runner.js
new file mode 100644
index 0000000..2c6218b
--- /dev/null
+++ b/script/Runner.js
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2017 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    CEA - initial API and implementation
+ */
+var Runner = (function (t) {
+
+	var Callback = (function(c, e, o)
+	{	
+	    function Callback(c, e, o) 
+	    {
+	    	this.callback = c;
+	    	this.errorCallback = e;
+	    	this.once = (o==undefined|o==null)?true
+	    			:(o===true?true:false);
+	    }
+
+		Callback.prototype.getCallback = function()
+		{
+			return this.callback;
+		}
+
+		Callback.prototype.getErrorCallback = function()
+		{
+			return this.errorCallback;
+		}
+	    	
+		Callback.prototype.runOnce = function()
+		{
+			return this.once;
+		}
+		
+		return Callback;
+	}());
+	
+	
+	var Request = (function(i, m, u, c, h)
+	{	
+	    function Request(i, m, u, c, h) 
+	    {
+	    	this.id = i;
+	    	this.method = m;
+	    	if(this.method == null)
+	    	{
+	    		this.method = (c==null?"GET":"POST");
+	    	}
+	    	this.uri = u;
+	    	this.content = c;
+	    	this.headers = h;
+	    }
+
+	    Request.prototype.getId = function()
+	    {
+	    	return this.id;
+	    }
+	    
+		Request.prototype.getMethod = function()
+		{
+			return this.method;
+		}
+	    	
+		Request.prototype.getUri = function()
+		{
+			return this.uri;
+		}
+
+		Request.prototype.getContent = function()
+		{
+			return this.content;
+		}
+		
+		Request.prototype.getHeaders = function()
+		{
+			return this.headers;
+		}
+		
+		return Request;
+	}());
+	
+    function Runner(t) {
+    	
+    	this.lifo = []; 
+    	this.map = {};
+    	this.transmitter = t;
+    	this.running = false;
+    	this.continueToWait = false; 
+    	
+        this.run = function()
+    	{
+    		if(!this.running || this.transmitter == undefined)
+    		{
+    			return;
+    		}
+    		if(this.lifo.length > 0)
+    		{
+	    		var r = this.lifo.shift();	
+	    		if(r != null)
+	    		{
+	    			this.execute(r);
+	    		}
+    		} 
+    		setTimeout(function(){this.run();}.bind(this),250);
+    		
+    	}.bind(this);
+    	
+    	this.execute = function(r)
+    	{
+    		if(!this.running)
+    		{
+    			return;
+    		}    		
+    		if(!this.transmitter.isAvailable())
+    		{
+    			setTimeout(function(){this.execute(r);}.bind(this),500);
+    			return;
+    		}
+    		var id = r.getId();
+    		var uri = r.getUri();
+    		var method = r.getMethod();
+    		var content = r.getContent();
+    		var headers = r.getHeaders();
+    		
+    		this.transmitter.reset(); 
+            this.transmitter.send(id, method, uri, content, headers);
+            
+    	}.bind(this);
+    	
+    	this.waiting = function()
+    	{
+    		if(!this.running)
+    		{
+    			return;
+    		}    		
+    		if(!this.transmitter.isAvailable())
+    		{
+    			setTimeout(function(){this.waiting();}.bind(this),500);
+    			return;
+    		}    		
+    		if(this.transmitter.inError())
+    		{
+    			console.error(this.transmitter.getError());
+    			this.transmitter.reset();
+    			
+    		} else if(this.transmitter.getSize() > 0)
+    		{
+    			this.transmitter.getLock();
+    			var ms = this.transmitter.getMessages();
+    			
+    			while(ms.length > 0)
+    			{
+    				var m = ms.shift();
+    				var d = m.data==undefined?m:m.data;
+    				var i = m.rid;
+    				if(i == undefined || i == null)
+    				{
+    					i = m.callbackId;
+        				if(i == undefined || i == null)
+        				{
+        					i = "DEFAULT";
+        				}
+    				}
+    				var callback = this.getMapping(i);
+    				if(callback == undefined)
+    				{
+    					callback = new Callback( function(d){
+    					    console.log("Request identifier " + i + " \n " + d);},
+    						     null,false);
+    				}
+    				(callback.getCallback())(d);
+    				if(callback.runOnce())
+    				{
+    					this.removeMapping(i);
+    				}
+    			}    			
+    			this.transmitter.releaseLock();
+    		}
+    		setTimeout(function(){this.waiting();}.bind(this),250);
+    		
+    	}.bind(this);
+    }
+	
+	Runner.prototype.start = function()
+	{
+		this.running = true;
+		this.waiting();
+		this.run();
+	};
+	
+	Runner.prototype.stop = function()
+	{
+		this.transmitter.close();
+		this.running = false;
+	};
+
+	Runner.prototype.error = function(e)
+	{
+		console.error(e);
+	};
+
+	Runner.prototype.push = function(id, method, uri, content, headers,
+		callback, errorCallback, once)
+	{
+		var identifier = id;
+		if(identifier!=null && callback!=null)
+		{
+			this.setMapping(identifier, callback, errorCallback, once);
+		}
+		var r = new Request(identifier, method, uri, content, headers);
+		this.lifo.push(r);
+	};
+
+	Runner.prototype.setMapping = function(id, fun, errFun, once)
+	{ 
+		var identifier = id;
+		if(identifier == undefined || identifier == null)
+		{ 
+			console.error("callback identifier expected");
+			return;
+		}
+		var callback = new Callback(fun, errFun, once);
+		this.map[identifier] = callback;
+	};
+
+	Runner.prototype.getMapping = function(id)
+	{ 
+		var identifier = id;
+		if(identifier == undefined || identifier == null)
+		{ 
+			identifier = "DEFAULT";
+		}
+		return this.map[identifier];
+	};  	
+
+	Runner.prototype.removeMapping = function(id)
+	{ 
+		if(id == null || id == undefined)
+		{ 
+			return;
+		}
+		delete this.map[id];
+	};  	
+	
+	return Runner;
+	
+}());  
diff --git a/script/Transmitter.js b/script/Transmitter.js
new file mode 100644
index 0000000..d18f445
--- /dev/null
+++ b/script/Transmitter.js
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2017 CEA.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    CEA - initial API and implementation
+ */
+var Transmitter = (function(gw, url){
+	
+	function Transmitter (gw ,url)
+	{    	
+		this.gateway = gw;
+		this.baseUrl = url;
+    	this.token = null;
+    	this.messages = [];
+    	this.buffer = [];
+    	
+    	this.lock = false;
+    	this.available = false;
+    	this.inerror = false;
+    	this.error = null;
+    	
+		this.onopen = function(evt)
+		{ 
+			this.available = true; 
+			
+		}.bind(this);
+		
+		this.onclose = function(evt)
+		{ 
+			this.available = false;		
+			
+		}.bind(this);
+		
+		this.onerror = function(evt)
+		{ 
+			this.inerror = true; 			
+			this.error = evt;
+			
+		}.bind(this);
+		
+		this.onmessage = function(evt)
+		{
+			var json = null;
+			try
+			{
+			    json = JSON.parse(evt.data);
+			} catch(err)
+			{
+				json={};
+				json["message"]=evt.data;
+			}
+			var rid = json["rid"];
+			if(rid == undefined)
+			{
+			   rid =json["callbackId"];
+			}
+			evt.rid = rid;
+			if(evt.token == undefined || evt.token == null)
+			{
+				evt.token=json["token"];
+			}
+			if(this.lock)
+			{			
+				this.buffer.push(evt);
+				
+			} else
+			{
+				if(this.buffer.length > 0)
+				{
+					this.messages.concat(this.buffer);
+					this.buffer = [];
+				}	
+				this.messages.push(evt);
+			}	
+			if(!(this.gateway.getAuthentication() instanceof Token) && evt.token!=null)
+			{
+				this.gateway.setAuthentication(new Token(evt.token));
+				console.log("Transmitter authentication updated : " + evt.token);
+			}		
+		}.bind(this);
+		
+		this.onsend = null;
+	}
+
+    Transmitter.prototype.send = function (method, path, parameters, headers)
+    {
+    	if(this.onsend == null)
+    	{
+    		return;
+    	}
+    	this.onsend(method, path, parameters, headers);
+    };
+	
+	Transmitter.prototype.isAvailable = function(){ return this.available; };
+
+	Transmitter.prototype.inError = function(){ return this.inerror; };
+
+	Transmitter.prototype.getError = function(){ return this.error; };
+
+	Transmitter.prototype.getSize = function(){ return this.messages.length; };
+	
+	Transmitter.prototype.getMessages = function()
+	{ 
+		var ms = [];
+		while(this.messages.length > 0 )
+		{
+			ms.push(this.messages.pop());
+		}
+		return ms; 
+	};
+
+	Transmitter.prototype.getLock = function(){ return this.lock = true};
+
+	Transmitter.prototype.releaseLock = function(){ return this.lock = false; };
+	
+	Transmitter.prototype.reset = function()
+	{ 
+		this.error = null;
+		this.inerror = false;
+	};
+	
+	return Transmitter;
+}());
+
+var WebSocketTransmitter = (new function (gw, url){
+	
+	function WebSocketTransmitter(gw, url)
+	{
+		Transmitter.call(this, gw, url);	
+		if(this.baseUrl!=null)
+		{
+			this.webSocket = new WebSocket(this.baseUrl);
+			this.webSocket.onopen = this.onopen;
+			this.webSocket.onclose = this.onclose;
+			this.webSocket.onerror = this.onerror;
+			this.webSocket.onmessage = this.onmessage;
+		}
+		
+		this.onsend = function(id, method, path, parameters, headers)
+		{			
+			var args = null;
+			if(parameters==null)
+			{
+				args = [];
+				
+			} else 
+			{
+				args = parameters;
+			}
+			var json = {};
+			json["rid"] = id;
+			json["uri"] = path;
+
+			if(headers == null)
+			{
+				headers = [];
+			}			
+            if(parameters != null)
+            {
+            	json["parameters"] = JSON.parse(parameters);
+
+				 for(var i=0;i<headers.length;i++)
+				 { 
+					 var name = headers[i].name;
+					 var value = headers[i].value;
+					 if(name!=null && value!=null)
+					 { 
+						 json[name]=value;
+				     }
+				 }
+            }	
+            if(this.gateway.getAuthentication()!=null)
+            {
+            	json[this.gateway.getAuthentication().getHeaderKey()] = 
+            		this.gateway.getAuthentication().getHeaderValue();
+            }
+            var content = JSON.stringify(json);
+			this.webSocket.send(content);
+			
+		}.bind(this);
+	};
+	
+	WebSocketTransmitter.prototype.close = function()
+	{
+		this.webSocket.close();
+	};
+	
+	return WebSocketTransmitter;
+}());
+
+WebSocketTransmitter.prototype = Object.create(Transmitter.prototype);
+
+var HttpTransmitter = (new function (gw, url){
+	
+	var Ajax = (new function(){
+		
+		function Ajax() {}
+		
+		Ajax.prototype.newRequest = function()
+		{
+			var xhr = null;
+			if (window.XMLHttpRequest || window.ActiveXObject)
+			{
+				if (window.ActiveXObject) 
+				{
+					try 
+					{
+						xhr  = new ActiveXObject("Msxml2.XMLHTTP");
+						
+					} catch(e)
+					{
+						xhr  = new ActiveXObject("Microsoft.XMLHTTP");
+					}
+				} else
+				{
+					xhr  = new XMLHttpRequest(); 
+					
+				}
+			} else 
+			{
+				alert("XMLHTTPRequest is not handled by your browser");
+			}
+			return xhr;
+		};
+		
+		return Ajax;
+		
+	}());
+	
+	function HttpTransmitter(gw, url)
+	{
+		Transmitter.call(this, gw, url);
+		this.ajax = new Ajax(); 
+		this.onopen();
+		
+		this.onsend = function(id, method, path, parameters, headers)
+		{		 
+			var url = this.baseUrl +  path;
+			var content = null;
+			
+			if(headers == null)
+			{
+				headers = [];
+			}			
+			if(parameters != null)
+			{
+				var jcontent = JSON.parse(parameters);
+				content = JSON.stringify(jcontent);
+			}
+			var xhr = this.ajax.newRequest();
+			headers.push({"name":"Accept", "value": "application/json"});
+			headers.push({"name":"X-Requested-With", "value": "XmlHttpRequest"});
+			headers.push({"name":"rid", "value": id});
+			
+			if(this.gateway.getAuthentication() != null)
+			{
+				headers.push({
+				"name" : this.gateway.getAuthentication().getHeaderKey(),
+				"value": this.gateway.getAuthentication().getHeaderValue()
+				});
+			}
+			if(method == "GET")
+			{
+				 xhr.open("GET", url, true);
+				 
+			 } else
+			 {
+				 xhr.open("POST", url, true);
+				 headers.push({"name":"Content-Type", "value": "application/json"});
+			 }
+			 for(var i=0;i<headers.length;i++)
+			 { 
+				 var name = headers[i].name;
+				 var value = headers[i].value;
+				 if(name!=null && value!=null)
+				 { 
+					 xhr.setRequestHeader(name,value);
+			     }
+			 }
+			 xhr.onreadystatechange = function()
+			 {
+		        if(xhr.readyState==4)
+		        {
+					if (xhr.status >= 200 && xhr.status < 400)
+					{
+					   this.onmessage({
+						   data  : xhr.response, 
+						   token : xhr.getResponseHeader("X-Auth-Token")
+					   });
+					   return;
+					}
+					if(xhr.status >= 400)
+					{
+					   var message = {
+						  "status"  : xhr.status, 
+						  "message" : xhr.response};
+					   this.onerror({
+						   data  : message, 
+						   token : xhr.getResponseHeader("X-Auth-Token")
+					   });
+					}
+		        }
+			 }.bind(this);
+			 
+			 xhr.onerror= function(e)
+			 {
+				console.error(e);
+				
+			 }.bind(this);
+			 
+			 xhr.send(content);
+			 
+		}.bind(this);
+	};
+
+	HttpTransmitter.prototype.close = function()
+	{
+		this.onclose(null);
+	};
+	
+	return HttpTransmitter;
+}());
+
+HttpTransmitter.prototype = Object.create(Transmitter.prototype);
diff --git a/script/about.txt b/script/about.txt
new file mode 100644
index 0000000..9a75f5e
--- /dev/null
+++ b/script/about.txt
@@ -0,0 +1,22 @@
+About This Content
+
+June 5, 2006
+
+License
+
+The Eclipse Foundation makes available all content in this 
+plug-in ("Content"). Unless otherwise indicated below, the 
+Content is provided to you under the terms and conditions 
+of the Eclipse Public License Version 1.0 ("EPL"). A copy 
+of the EPL is available at http://www.eclipse.org/legal/epl-v10.html. 
+For purposes of the EPL, "Program" will mean the Content.
+
+If you did not receive this Content directly from the Eclipse 
+Foundation, the Content is being redistributed by another party 
+("Redistributor") and different terms and conditions may apply 
+to your use of any object code in the Content. Check the 
+Redistributor's license that was provided with the Content. 
+If no such license exists, contact the Redistributor. Unless 
+otherwise indicated below, the terms and conditions of the EPL 
+still apply to any source code in the Content and such source 
+code may be obtained at http://www.eclipse.org