com.jwebmp.websockets.services.websockets.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-websockets Show documentation
Show all versions of jwebmp-websockets Show documentation
Provides Asynchronous and Dynamic Log Handler support for JDK1.8 logging API.
Access via LogFactory.
The newest version!
jw.websocket={};jw.websocket.connected=false;jw.websocket.pollTime=5000;jw.websocket.pollCount=1;jw.websocket.queuedMessages=[];var wsAddy=jw.siteAddress.replace("http","ws");wsAddy=wsAddy.replace("https","ws");jw.websocket.address=wsAddy+"jwebmpwssocket";jw.websocket.reconnect=function(){jw.websocket.connection=new WebSocket(jw.websocket.address);jw.websocket.connected=true};jw.websocket.reconnect();jw.websocket.connection.onmessage=function(a){console.log(a.data);try{jw.actions.processResponse(a.data,$scope,$parse,$timeout,$compile)}catch(a){console.log("This doesn't look like a valid JSON: "+a.data)}};jw.websocket.authdataproviders=[];jw.websocket.connection.onopen=function(b){jw.websocket.reconnectTimer.stop();jw.websocket.connected=true;if(jw.websocket.timer){jw.websocket.timer.start()}WS_AUTH_DATA_PROVIDER_LOAD;var a={};$.each(jw.websocket.authdataproviders,function(f){var c=this.name;var d=this.data;a[c]=d});jw.websocket.newMessage("Auth",a)};jw.websocket.connection.onclose=function(a){console.log("on close "+a.data);jw.websocket.connected=false};jw.websocket.connection.onerror=function(a){console.log("on error "+a.data);jw.websocket.connected=false};jw.websocket.sendPlainTextMessage=function(b){jw.websocket.newMessage("PlainText",{message:b})};jw.websocket.newMessage=function(b,c){var a={};a.action=b;a.data=c;a.data.sessionid=jw.sessionid[0].replace("JSESSIONID=","");jw.websocket.queuedMessages.push(a)};jw.websocket.newMessageNow=function(b,c){var a={};a.action=b;a.data=c;a.data.sessionid=jw.sessionid[0].replace("JSESSIONID=","");jw.websocket.connection.send(JSON.stringify(a))};jw.websocket.timer=new DeltaTimer(function(c){if(jw.websocket.queuedMessages.length>0){if(jw.websocket.connected){try{var a=jw.websocket.queuedMessages.length;while(a--){jw.websocket.connection.send(JSON.stringify(jw.websocket.queuedMessages[a]));jw.websocket.queuedMessages.splice(a,1)}}catch(b){}}else{jw.websocket.reconnect()}}},500,jw.websocket.timer);jw.websocket.timerobj=jw.websocket.timer.start();jw.websocket.reconnectTimer=new DeltaTimer(function(a){if(!jw.websocket.connected){jw.websocket.timer.stop();jw.websocket.reconnect();jw.websocket.pollCount++;jw.websocket.reconnectTimer.delay=Math.max(jw.websocket.pollCount*jw.websocket.pollTime,0)}else{jw.websocket.pollCount=1}},10000,jw.websocket.reconnectTimer);jw.websocket.reconnectTimerObject=jw.websocket.reconnectTimer.start();