text: "use strict";module.exports=(function(){var e="ws://localhost/ws";var g;var p={};var b={};var l={};var v;var y=false;var z=d;var r=s;var x=require("websocket").w3cwebsocket;function t(){z("CONNECTING to "+e);v=new x(e);v.onopen=function(A){h(A)};v.onclose=function(A){f(A)};v.onmessage=function(A){u(A)};v.onerror=function(A){i(A)}}function h(A){if(v.readyState==x.OPEN){k(g);y=true}z("CONNECTED")}function f(A){z("DISCONNECTED");y=false}function u(A){v.send(".");if(A.data!="ping"){try{var B=JSON.parse(A.data);if(B.data.hasOwnProperty("_MESSAGE_ID")&&l.hasOwnProperty(B.data._MESSAGE_ID)){var C=l[B.data._MESSAGE_ID];if((+new Date)<C.expiration){delete B.data._MESSAGE_ID;C.fn(B.data)}delete l[B.data._MESSAGE_ID]}else{if(p[B.recipient]!==undefined){p[B.recipient](B)}else{z("no handler for event: "+A.data)}}}catch(B){z("ERROR: parse exception for event data "+A.data)}z("RESPONSE: "+A.data)}}function i(A){r();z("ERROR: "+A)}function o(A){if(!v||v.readyState==x.CONNECTING){setTimeout(function(){o(A)},200)}else{A()}}function k(A){if(v&&v.send(A)){z("SENT: "+A)}}function n(){v&&v.close()}function d(A){}function s(){}function c(A,B){y&&k("sendjson "+A+" "+JSON.stringify(B))}function m(C,E,D,B){if(y){var A=q();l[A]={expiration:(+new Date)+D,fn:B};E._MESSAGE_ID=A;E._MESSAGE_HANDLE=C;k("sendjson "+C+" "+JSON.stringify(E))}}function a(B,A){if(y){b[B]={fn:A};j(B,function(D){var C={_MESSAGE_ID:D.data._MESSAGE_ID};A(D.data,C);c(D.sender,C)})}}function j(B,A){if(y){k("subscribe "+B);p[B]=A}}function w(A){if(y){k("unsubscribe "+A);p[A]=function(){}}}function q(){function A(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return A()+A()+"-"+A()+"-"+A()+"-"+A()+"-"+A()+A()+A()}return{connect:function(C,B,A){e=C;g=B&&B.length>0?B:"webclient_"+ +(new Date());p[B]=A;t()},send:function(B,A){o(function(){c(B,A)})},call:function(B,D,C,A){o(function(){m(B,D,C,A)})},register:function(B,A){o(function(){a(B,A)})},subscribe:function(B,A){o(function(){j(B,A)})},unsubscribe:function(A){o(function(){w(A)})},variable:function(E,B){var D=[];var F;function C(G){D.forEach(function(H){H(G)})}function A(G){if(arguments.length&&G!==F){F=G;C(G);c(E,{name:F})}return F}A.subscribe=function(G){D.push(G)};this.subscribe(E,function(G){if(G.data.hasOwnProperty(B)){A(G.data[B])}});return A},isConnected:function(){return y},close:function(){o(function(){n()})},handlers:function(){return p},logger:function(A){z=A},error:function(A){r=A}}})();
  