From 560e0888ee4f6fc7143985401bf2673ecf2071fe Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Tue, 24 Nov 2015 20:16:51 -0500 Subject: [PATCH] Update minified version of library --- reconnecting-websocket.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reconnecting-websocket.min.js b/reconnecting-websocket.min.js index 3015099..2caf895 100644 --- a/reconnecting-websocket.min.js +++ b/reconnecting-websocket.min.js @@ -1 +1 @@ -!function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()}(this,function(){function a(b,c,d){function l(a,b){var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!1,!1,b),c}var e={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i=!1,j=!1,k=document.createElement("div");k.addEventListener("open",function(a){g.onopen(a)}),k.addEventListener("close",function(a){g.onclose(a)}),k.addEventListener("connecting",function(a){g.onconnecting(a)}),k.addEventListener("message",function(a){g.onmessage(a)}),k.addEventListener("error",function(a){g.onerror(a)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b){h=new WebSocket(g.url,c||[]),b||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d=h,e=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=!0,d.close(),j=!1},g.timeoutInterval);h.onopen=function(){clearTimeout(e),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d=l("open");d.isReconnect=b,b=!1,k.dispatchEvent(d)},h.onclose=function(c){if(clearTimeout(e),h=null,i)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d=l("connecting");d.code=c.code,d.reason=c.reason,d.wasClean=c.wasClean,k.dispatchEvent(d),b||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(!0)},e>g.maxReconnectInterval?g.maxReconnectInterval:e)}},h.onmessage=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b.data);var c=l("message");c.data=b.data,k.dispatchEvent(c)},h.onerror=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b),k.dispatchEvent(l("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(b){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b),h.send(b);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a,b){"undefined"==typeof a&&(a=1e3),i=!0,h&&h.close(a,b)},this.refresh=function(){h&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=!1,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a}); +!function(e,n){"function"==typeof define&&define.amd?define([],n):"undefined"!=typeof module&&module.exports?module.exports=n():e.ReconnectingWebSocket=n()}(this,function(){function e(n,t,o){function c(e,n){var t=document.createEvent("CustomEvent");return t.initCustomEvent(e,!1,!1,n),t}var i={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3,maxReconnectAttempts:null,binaryType:"blob"};o||(o={});for(var r in i)"undefined"!=typeof o[r]?this[r]=o[r]:this[r]=i[r];this.url=n,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var s,u=this,a=!1,d=!1,l=document.createElement("div");l.addEventListener("open",function(e){u.onopen(e)}),l.addEventListener("close",function(e){u.onclose(e)}),l.addEventListener("connecting",function(e){u.onconnecting(e)}),l.addEventListener("message",function(e){u.onmessage(e)}),l.addEventListener("error",function(e){u.onerror(e)}),this.addEventListener=l.addEventListener.bind(l),this.removeEventListener=l.removeEventListener.bind(l),this.dispatchEvent=l.dispatchEvent.bind(l),this.open=function(n){if(s=new WebSocket(u.url,t||[]),s.binaryType=this.binaryType,n){if(this.maxReconnectAttempts&&this.reconnectAttempts>this.maxReconnectAttempts)return}else l.dispatchEvent(c("connecting")),this.reconnectAttempts=0;(u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",u.url);var o=s,i=setTimeout(function(){(u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",u.url),d=!0,o.close(),d=!1},u.timeoutInterval);s.onopen=function(t){clearTimeout(i),(u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onopen",u.url),u.protocol=s.protocol,u.readyState=WebSocket.OPEN,u.reconnectAttempts=0;var o=c("open");o.isReconnect=n,n=!1,l.dispatchEvent(o)},s.onclose=function(t){if(clearTimeout(i),s=null,a)u.readyState=WebSocket.CLOSED,l.dispatchEvent(c("close"));else{u.readyState=WebSocket.CONNECTING;var o=c("connecting");o.code=t.code,o.reason=t.reason,o.wasClean=t.wasClean,l.dispatchEvent(o),n||d||((u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onclose",u.url),l.dispatchEvent(c("close")));var i=u.reconnectInterval*Math.pow(u.reconnectDecay,u.reconnectAttempts);setTimeout(function(){u.reconnectAttempts++,u.open(!0)},i>u.maxReconnectInterval?u.maxReconnectInterval:i)}},s.onmessage=function(n){(u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",u.url,n.data);var t=c("message");t.data=n.data,l.dispatchEvent(t)},s.onerror=function(n){(u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onerror",u.url,n),l.dispatchEvent(c("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(n){if(s)return(u.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","send",u.url,n),s.send(n);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(e,n){"undefined"==typeof e&&(e=1e3),a=!0,s&&s.close(e,n)},this.refresh=function(){s&&s.close()}}if("WebSocket"in window)return e.prototype.onopen=function(e){},e.prototype.onclose=function(e){},e.prototype.onconnecting=function(e){},e.prototype.onmessage=function(e){},e.prototype.onerror=function(e){},e.debugAll=!1,e.CONNECTING=WebSocket.CONNECTING,e.OPEN=WebSocket.OPEN,e.CLOSING=WebSocket.CLOSING,e.CLOSED=WebSocket.CLOSED,e});