diff --git a/realtime-pluginfree-calls/README.md b/realtime-pluginfree-calls/README.md index 1aa442f5..5a5057cb 100644 --- a/realtime-pluginfree-calls/README.md +++ b/realtime-pluginfree-calls/README.md @@ -1,6 +1,11 @@ -##### [WebRTC Browser-to-Browser Pluginfree Calls](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/realtime-pluginfree-calls) / [Demo](https://www.webrtc-experiment.com/calls/) +## [WebRTC 1:1 Pluginfree Calls](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/realtime-pluginfree-calls) - +Demos: + +1. https://www.webrtc-experiment.com/realtime-pluginfree-calls/ +2. https://www.webrtc-experiment.com/calls/ + + This [WebRTC](https://www.webrtc-experiment.com/) demo setups one-to-one audio/video/screen calls between two users. @@ -8,11 +13,9 @@ Users can set unique identifiers (userids) for them; and target users can call t It supports realtime text-chat as well; where websocket/socket.io is used for text sharing. -Try the demo: https://www.webrtc-experiment.com/calls/ - = -##### Browser Support +## Browser Support [Audio-Only calling experiment](https://www.webrtc-experiment.com/calls/) works fine on following web-browsers: @@ -25,6 +28,6 @@ Try the demo: https://www.webrtc-experiment.com/calls/ = -#### License +## License -All [WebRTC Experiments](https://www.webrtc-experiment.com/) are released under [MIT licence](https://www.webrtc-experiment.com/licence/) . Copyright (c) [Muaz Khan](https://plus.google.com/+MuazKhan). +[1:1 Calls based demos](https://github.com/muaz-khan/WebRTC-Experiment/tree/master/realtime-pluginfree-calls) are released under [MIT licence](https://www.webrtc-experiment.com/licence/) . Copyright (c) [Muaz Khan](https://plus.google.com/+MuazKhan). diff --git a/realtime-pluginfree-calls/images/video-container.png b/realtime-pluginfree-calls/images/video-container.png deleted file mode 100644 index 0863d51c..00000000 Binary files a/realtime-pluginfree-calls/images/video-container.png and /dev/null differ diff --git a/realtime-pluginfree-calls/index.html b/realtime-pluginfree-calls/index.html index 31dad31e..cdc86fa9 100644 --- a/realtime-pluginfree-calls/index.html +++ b/realtime-pluginfree-calls/index.html @@ -1,8 +1,24 @@ -WebRTC 1-1 Calls + + + +WebRTC 1:1 Calls ® Muaz Khan - + + + + + + + + + + + + + +
@@ -32,7 +48,7 @@

Alert Box

@@ -43,8 +59,13 @@

Alert Box

- + + + + + - \ No newline at end of file + + \ No newline at end of file diff --git a/realtime-pluginfree-calls/js/PeerConnection.js b/realtime-pluginfree-calls/js/PeerConnection.js index 087fa65e..af1d4613 100644 --- a/realtime-pluginfree-calls/js/PeerConnection.js +++ b/realtime-pluginfree-calls/js/PeerConnection.js @@ -154,8 +154,7 @@ }, false); function onmessage(message) { - console.log(root.userid, onmessage); - if (message.userid == root.userid) return; + // if (message.userid == root.userid) return; if (message.customMessage) { if (root.onCustomMessage) root.onCustomMessage(message); @@ -304,8 +303,15 @@ }; peer.onicecandidate = function (event) { - if (event.candidate) - config.onicecandidate(event.candidate); + config.onicecandidate(event.candidate); + }; + + peer.oniceconnectionstatechange = function() { + console.log('oniceconnectionstatechange', JSON.stringify({ + iceConnectionState: peer.iceConnectionState, + iceGatheringState: peer.iceGatheringState, + signalingState: peer.signalingState + }, null, '\t')); }; peer.createOffer(function (sdp) { @@ -339,8 +345,15 @@ }; peer.onicecandidate = function (event) { - if (event.candidate) - config.onicecandidate(event.candidate); + config.onicecandidate(event.candidate); + }; + + peer.oniceconnectionstatechange = function() { + console.log('oniceconnectionstatechange', JSON.stringify({ + iceConnectionState: peer.iceConnectionState, + iceGatheringState: peer.iceGatheringState, + signalingState: peer.signalingState + }, null, '\t')); }; peer.setRemoteDescription(new RTCSessionDescription(config.sdp)); @@ -372,24 +385,5 @@ function onSdpError() {} window.URL = window.webkitURL || window.URL; - navigator.getMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; - navigator.getUserMedia = function (hints, onsuccess, onfailure) { - if (!hints) hints = { - audio: true, - video: true - }; - if (!onsuccess) throw 'Second argument is mandatory. navigator.getUserMedia(hints,onsuccess,onfailure)'; - - navigator.getMedia(hints, _onsuccess, _onfailure); - - function _onsuccess(stream) { - onsuccess(stream); - } - - function _onfailure(e) { - if (onfailure) onfailure(e); - else throw Error('getUserMedia failed: ' + JSON.stringify(e, null, '\t')); - } - }; - + navigator.getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia; })(); diff --git a/realtime-pluginfree-calls/js/indexedDB.js b/realtime-pluginfree-calls/js/indexedDB.js deleted file mode 100644 index d57ad3c4..00000000 --- a/realtime-pluginfree-calls/js/indexedDB.js +++ /dev/null @@ -1,97 +0,0 @@ -// this indexed-db code is taken from a repository on github; sorry forgot the link. -// WebRTC realtime Calls!!! (part of WebRTC Experiments by Muaz Khan!) @WebRTCWeb - -// https://wwww.webrtc-experiment.com/ - -// Muaz Khan - www.MuazKhan.com -// MIT License - www.webrtc-experiment.com/licence -// Experiments - github.com/muaz-khan/WebRTC-Experiment - -var imageURL = 'images/video-container.png'; - -(function () { - - // IndexedDB - var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.OIndexedDB || window.msIndexedDB, - dbVersion = 1.0; - - // Create/open database - var request = indexedDB.open("imageFiles", dbVersion), - db, - createObjectStore = function (dataBase) { - // Create an objectStore - console.log("Creating objectStore"); - dataBase.createObjectStore("image"); - }, - getImageFile = function () { - putElephantInDb(null, function () { - // Create XHR - var xhr = new XMLHttpRequest(), - blob; - - xhr.open("GET", imageURL, true); - // Set the responseType to blob - xhr.responseType = "blob"; - - xhr.addEventListener("load", function () { - if (xhr.status === 200) { - console.log("Image retrieved"); - - // Blob as response - blob = xhr.response; - var reader = new FileReader(); - reader.onload = function (e) { - putElephantInDb(e.target.result); - }; - reader.readAsDataURL(blob); - } - }, false); - // Send XHR - xhr.send(); - }); - }, - putElephantInDb = function (blob, failureCallback) { - var transaction = db.transaction(["image"], 'readwrite'); - if (blob) { - transaction.objectStore("image").put(blob, "image"); - } - transaction.objectStore("image").get("image").onsuccess = function (event) { - if (event.target.result) { - var imgElephant = document.getElementById("images-video-container-png"); - imgElephant.setAttribute("src", event.target.result); - imageURL = event.target.result; - } else if (failureCallback) failureCallback(); - }; - }; - - request.onerror = function () { - console.log("Error creating/accessing IndexedDB database"); - }; - - request.onsuccess = function () { - console.log("Success creating/accessing IndexedDB database"); - db = request.result; - - db.onerror = function () { - console.log("Error creating/accessing IndexedDB database"); - }; - - // Interim solution for Google Chrome to create an objectStore. Will be deprecated - if (db.setVersion) { - if (db.version != dbVersion) { - var setVersion = db.setVersion(dbVersion); - setVersion.onsuccess = function () { - createObjectStore(db); - getImageFile(); - }; - } else { - getImageFile(); - } - } else { - getImageFile(); - } - }; // For future use. Currently only in latest Firefox versions - request.onupgradeneeded = function (event) { - createObjectStore(event.target.result); - }; -})(); diff --git a/realtime-pluginfree-calls/js/script.js b/realtime-pluginfree-calls/js/script.js index bacbd200..9c47ade6 100644 --- a/realtime-pluginfree-calls/js/script.js +++ b/realtime-pluginfree-calls/js/script.js @@ -6,11 +6,20 @@ // MIT License - www.webrtc-experiment.com/licence // Experiments - github.com/muaz-khan/WebRTC-Experiment +// loading larger images as data-URLs across domains. +var imageURL = getBackgroundImage(); +var imgElephant = document.getElementById("images-video-container-png"); +imgElephant.setAttribute('src', imageURL); + +var chatSection = getElement('.chat-section'), + chatOutput = getElement('.chat-output'), + chatInput = getElement('.chat-input input'); + var channel = location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''); var sender = Math.round(Math.random() * 999999999) + 999999999; -// var SIGNALING_SERVER = 'https://webrtc-signaling.nodejitsu.com:443/'; -var SIGNALING_SERVER = 'https://www.webrtc-experiment.com:8000/'; +var SIGNALING_SERVER = 'https://webrtc-signaling.nodejitsu.com:443/'; +// var SIGNALING_SERVER = 'https://www.webrtc-experiment.com:8000/'; io.connect(SIGNALING_SERVER).emit('new-channel', { channel: channel, sender: sender @@ -18,7 +27,17 @@ io.connect(SIGNALING_SERVER).emit('new-channel', { var socket = io.connect(SIGNALING_SERVER + channel); socket.on('connect', function () { - console.log('Socket.io connection is opened.'); + chatInput.disabled = false; + appendMessage('Socket.io connection is opened.', 'System', 'System'); +}); + +socket.on('disconnect', function() { + chatInput.disabled = true; + appendMessage('Socket.io connection is disconnected.', 'System', 'System'); +}); + +socket.on('error', function () { + appendMessage('Socket.io connection failed.', 'System', 'System'); }); socket.send = function (message) { @@ -63,12 +82,7 @@ function getUserMedia(mediaType, callback) { audio: true, video: { optional: [], - mandatory: { - minWidth: 1920, - minHeight: 1080, - maxWidth: 1920, - maxHeight: 1080 - } + mandatory: {} } }; } @@ -76,16 +90,18 @@ function getUserMedia(mediaType, callback) { if (mediaType == 'screen') { hints = { audio: false, - video: { + video: !!navigator.webkitGetUserMedia ? { optional: [], mandatory: { - minWidth: 1280, - minHeight: 720, maxWidth: 1920, maxHeight: 1080, - minAspectRatio: 1.77, chromeMediaSource: 'screen' } + } : { + mozMediaSource: 'window', + mediaSource: 'window', + maxWidth: 1920, + maxHeight: 1080 } }; } @@ -105,6 +121,8 @@ function getUserMedia(mediaType, callback) { if (mediaType == 'audio') mediaElement.controls = true; else takeSnapshot(peer.userid, mediaElement); + }, function(error) { + alert( JSON.stringify(error, null, '\t') ); }); } @@ -171,10 +189,6 @@ function appendMessage(message, className, userid) { chatInput.focus(); } -var chatSection = getElement('.chat-section'), - chatOutput = getElement('.chat-output'), - chatInput = getElement('.chat-input input'); - chatInput.onkeyup = function (e) { if (e.keyCode != 13) return; @@ -346,8 +360,10 @@ peer.onStreamAdded = function (e) { smallPreview.innerHTML = ''; var mediaElementInMainPreviewBox = mainPreview.querySelector(peer.mediaType); - if (mediaElementInMainPreviewBox) + if (mediaElementInMainPreviewBox) { smallPreview.appendChild(mediaElementInMainPreviewBox); + mediaElementInMainPreviewBox.play(); + } mainPreview.appendChild(e.mediaElement); diff --git a/realtime-pluginfree-calls/js/socket.io.js b/realtime-pluginfree-calls/js/socket.io.js deleted file mode 100644 index 955e1905..00000000 --- a/realtime-pluginfree-calls/js/socket.io.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! Socket.IO.js build:0.9.0, development. Copyright(c) 2011 LearnBoost MIT Licensed */ -(function(n,t){var i=n;i.version="0.9.0",i.protocol=1,i.transports=[],i.j=[],i.sockets={},i.connect=function(n,r){var u=i.util.parseUri(n),o,f,e;return t&&t.location&&(u.protocol=u.protocol||t.location.protocol.slice(0,-1),u.host=u.host||(t.document?t.document.domain:t.location.hostname),u.port=u.port||t.location.port),o=i.util.uniqueUri(u),e={host:u.host,secure:"https"==u.protocol,port:u.port||("https"==u.protocol?443:80),query:u.query||""},i.util.merge(e,r),(e["force new connection"]||!i.sockets[o])&&(f=new i.Socket(e)),!e["force new connection"]&&f&&(i.sockets[o]=f),f=f||i.sockets[o],f.of(u.path.length>1?u.path:"")}})("object"==typeof module?module.exports:this.io={},this),(function(n,t){var i=n.util={},f=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,u=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],r;i.parseUri=function(n){var r=f.exec(n||""),i={},t=14;while(t--)i[u[t]]=r[t]||"";return i},i.uniqueUri=function(n){var u=n.protocol,i=n.host,r=n.port;return"document"in t?(i=i||document.domain,r=r||(u=="https"&&document.location.protocol!=="https:"?443:document.location.port)):(i=i||"localhost",r||u!="https"||(r=443)),(u||"http")+"://"+i+":"+(r||80)},i.query=function(n,t){var u=i.chunkQuery(n||""),f=[],r;i.merge(u,i.chunkQuery(t||""));for(r in u)u.hasOwnProperty(r)&&f.push(r+"="+u[r]);return f.length?"?"+f.join("&"):""},i.chunkQuery=function(n){for(var u={},r=n.split("&"),i=0,f=r.length,t;it.length?n:t,u=n.length>t.length?t:n,r=0,e=u.length;r0&&n.splice(0,1)[0]!=i.transport.name);n.length?o(n):i.publish("connect_failed")}}},i.options["connect timeout"]))})}i.sessionid=r,i.closeTimeout=f*1e3,i.heartbeatTimeout=u*1e3,i.transports=t.util.intersect(e.split(","),i.options.transports),o();i.once("connect",function(){clearTimeout(i.connectTimeoutTimer),n&&typeof n=="function"&&n()})}),this},r.prototype.packet=function(n){return this.connected&&!this.doBuffer?this.transport.packet(n):this.buffer.push(n),this},r.prototype.setBuffer=function(n){this.doBuffer=n,!n&&this.connected&&this.buffer.length&&(this.transport.payload(this.buffer),this.buffer=[])},r.prototype.disconnect=function(){if(this.connected){this.open&&this.of("").packet({type:"disconnect"});this.onDisconnect("booted")}return this},r.prototype.disconnectSync=function(){var i=t.util.request(),n=this.resource+"/"+t.protocol+"/"+this.sessionid;i.open("GET",n,!0);this.onDisconnect("booted")},r.prototype.isXDomain=function(){var n=i.location.port||("https:"==i.location.protocol?443:80);return this.options.host!==i.location.hostname||this.options.port!=n},r.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))},r.prototype.onOpen=function(){this.open=!0},r.prototype.onClose=function(){this.open=!1},r.prototype.onPacket=function(n){this.of(n.endpoint).onPacket(n)},r.prototype.onError=function(n){n&&n.advice&&this.options.reconnect&&n.advice==="reconnect"&&this.connected&&(this.disconnect(),this.reconnect()),this.publish("error",n&&n.reason?n.reason:n)},r.prototype.onDisconnect=function(n){var t=this.connected;this.connected=!1,this.connecting=!1,this.open=!1,t&&(this.transport.close(),this.transport.clearTimeouts(),this.publish("disconnect",n),"booted"!=n&&this.options.reconnect&&!this.reconnecting&&this.reconnect())},r.prototype.reconnect=function(){function i(){if(n.connected){for(var i in n.namespaces)n.namespaces.hasOwnProperty(i)&&""!==i&&n.namespaces[i].packet({type:"connect"});n.publish("reconnect",n.transport.name,n.reconnectionAttempts)}clearTimeout(n.reconnectionTimer),n.removeListener("connect_failed",t),n.removeListener("connect",t),n.reconnecting=!1,delete n.reconnectionAttempts,delete n.reconnectionDelay,delete n.reconnectionTimer,delete n.redoTransports,n.options["try multiple transports"]=r}function t(){if(!n.reconnecting)return;if(n.connected)return i();if(n.connecting&&n.reconnecting)return n.reconnectionTimer=setTimeout(t,1e3);if(n.reconnectionAttempts++=10},i.xdomainCheck=function(){return!0},typeof window!="undefined"&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),t.transports.push("flashsocket")})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);if("undefined"!=typeof window)var swfobject=function(){function v(){var i,r,n;if(c)return;try{i=t.getElementsByTagName("body")[0].appendChild(s("span")),i.parentNode.removeChild(i)}catch(u){return}for(c=!0,r=b.length,n=0;n0)for(r=0;r0){t=u(o);if(t)if(!g(h[r].swfVersion)||n.wk&&n.wk<312)if(h[r].expressInstall&&tt()){e={},e.data=h[r].expressInstall,e.width=t.getAttribute("width")||"0",e.height=t.getAttribute("height")||"0",t.getAttribute("class")&&(e.styleclass=t.getAttribute("class")),t.getAttribute("align")&&(e.align=t.getAttribute("align"));var p={},a=t.getElementsByTagName("param"),w=a.length;for(c=0;c');w.outerHTML='"+b+"",k[k.length]=t.id,v=u(t.id)}else{c=s(f),c.setAttribute("type",p);for(h in t)t[h]!=Object.prototype[h]&&(h.toLowerCase()=="styleclass"?c.setAttribute("class",t[h]):h.toLowerCase()!="classid"&&c.setAttribute(h,t[h]));for(l in r)r[l]!=Object.prototype[l]&&l.toLowerCase()!="movie"&&ri(c,l,r[l]);w.parentNode.replaceChild(c,w),v=c}}return v}function ri(n,t,i){var r=s("param");r.setAttribute("name",t),r.setAttribute("value",i),n.appendChild(r)}function ht(t){var i=u(t);i&&i.nodeName=="OBJECT"&&(n.ie&&n.win?(i.style.display="none",(function(){i.readyState==4?ii(t):setTimeout(arguments.callee,10)})()):i.parentNode.removeChild(i))}function ii(n){var t=u(n),i;if(t){for(i in t)typeof t[i]=="function"&&(t[i]=null);t.parentNode.removeChild(t)}}function u(n){var i=null;try{i=t.getElementById(n)}catch(r){}return i}function s(n){return t.createElement(n)}function dt(n,t,i){n.attachEvent(t,i),a[a.length]=[n,t,i]}function g(t){var r=n.pv,i=t.split(".");return i[0]=parseInt(i[0],10),i[1]=parseInt(i[1],10)||0,i[2]=parseInt(i[2],10)||0,r[0]>i[0]||r[0]==i[0]&&r[1]>i[1]||r[0]==i[0]&&r[1]==i[1]&&r[2]>=i[2]?!0:!1}function wt(r,u,o,h){var a,l,c;if(n.ie&&n.mac)return;a=t.getElementsByTagName("head")[0];if(!a)return;l=o&&typeof o=="string"?o:"screen",h&&(e=null,ot=null),e&&ot==l||(c=s("style"),c.setAttribute("type","text/css"),c.setAttribute("media",l),e=a.appendChild(c),n.ie&&n.win&&typeof t.styleSheets!=i&&t.styleSheets.length>0&&(e=t.styleSheets[t.styleSheets.length-1]),ot=l),n.ie&&n.win?e&&typeof e.addRule==f&&e.addRule(r,u):e&&typeof t.createTextNode!=i&&e.appendChild(t.createTextNode(r+" {"+u+"}"))}function l(n,t){if(!bt)return;var i=t?"visible":"hidden";c&&u(n)?u(n).style.visibility=i:wt("#"+n,"visibility:"+i)}function st(n){var r=/[\\\"<>\.;]/,t=r.exec(n)!=null;return t&&typeof encodeURIComponent!=i?encodeURIComponent(n):n}var i="undefined",f="object",at="Shockwave Flash",ti="ShockwaveFlash.ShockwaveFlash",p="application/x-shockwave-flash",lt="SWFObjectExprInst",yt="onreadystatechange",r=window,t=document,o=navigator,vt=!1,b=[ni],h=[],k=[],a=[],y,d,ut,ct,c=!1,w=!1,e,ot,bt=!0,n=function(){var a=typeof t.getElementById!=i&&typeof t.getElementsByTagName!=i&&typeof t.createElement!=i,s=o.userAgent.toLowerCase(),e=o.platform.toLowerCase(),l=e?/win/.test(e):/win/.test(s),y=e?/mac/.test(e):/mac/.test(s),v=/webkit/.test(s)?parseFloat(s.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,h=!1,u=[0,0,0],n=null,c;if(typeof o.plugins!=i&&typeof o.plugins[at]==f)n=o.plugins[at].description,!n||typeof o.mimeTypes!=i&&o.mimeTypes[p]&&!o.mimeTypes[p].enabledPlugin||(vt=!0,h=!1,n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),u[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10),u[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10),u[2]=/[a-zA-Z]/.test(n)?parseInt(n.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof r.ActiveXObject!=i)try{c=new ActiveXObject(ti),c&&(n=c.GetVariable("$version"),n&&(h=!0,n=n.split(" ")[1].split(","),u=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]))}catch(w){}return{w3:a,pv:u,wk:v,ie:h,win:l,mac:y}}(),ei=function(){if(!n.w3)return;(typeof t.readyState!=i&&t.readyState=="complete"||typeof t.readyState==i&&(t.getElementsByTagName("body")[0]||t.body))&&v(),c||(typeof t.addEventListener!=i&&t.addEventListener("DOMContentLoaded",v,!1),n.ie&&n.win&&(t.attachEvent(yt,function(){t.readyState=="complete"&&(t.detachEvent(yt,arguments.callee),v())}),r==top&&(function(){if(c)return;try{t.documentElement.doScroll("left")}catch(n){setTimeout(arguments.callee,0);return}v()})()),n.wk&&(function(){if(c)return;if(!/loaded|complete/.test(t.readyState)){setTimeout(arguments.callee,0);return}v()})(),pt(v))}(),fi=function(){n.ie&&n.win&&window.attachEvent("onunload",function(){for(var e=a.length,u,i,r,f,t=0;t= 10.0.0 is required.");return}location.protocol=="file:"&&n.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(n,t,i,r,u){var f=this;f.__id=WebSocket.__nextId++,WebSocket.__instances[f.__id]=f,f.readyState=WebSocket.CONNECTING,f.bufferedAmount=0,f.__events={},t?typeof t=="string"&&(t=[t]):t=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(f.__id,n,t,i||null,r||0,u||null)})},0)},WebSocket.prototype.send=function(n){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var t=WebSocket.__flash.send(this.__id,encodeURIComponent(n));return t<0?!0:(this.bufferedAmount+=t,!1)},WebSocket.prototype.close=function(){if(this.readyState==WebSocket.CLOSED||this.readyState==WebSocket.CLOSING)return;this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id)},WebSocket.prototype.addEventListener=function(n,t){n in this.__events||(this.__events[n]=[]),this.__events[n].push(t)},WebSocket.prototype.removeEventListener=function(n,t){var u,r;if(!(n in this.__events))return;for(u=this.__events[n],r=u.length-1;r>=0;--r)if(u[r]===t){u.splice(r,1);break}},WebSocket.prototype.dispatchEvent=function(n){for(var r=this.__events[n.type]||[],i,t=0;t"),this.doc.close(),this.doc.parentWindow.s=this,n=this.doc.createElement("div"),n.className="socketio",this.doc.body.appendChild(n),this.iframe=this.doc.createElement("iframe"),n.appendChild(this.iframe),r=this,i=t.util.query(this.socket.options.query,"t="+ +new Date),this.iframe.src=this.prepareUrl()+i;t.util.on(window,"unload",function(){r.destroy()})},i.prototype._=function(n,t){this.onData(n);try{var i=t.getElementsByTagName("script")[0];i.parentNode.removeChild(i)}catch(r){}},i.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(n){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,CollectGarbage()}},i.prototype.close=function(){return this.destroy(),t.Transport.XHR.prototype.close.call(this)},i.check=function(){if(typeof window!="undefined"&&"ActiveXObject"in window)try{var n=new ActiveXObject("htmlfile");return n&&t.Transport.XHR.check()}catch(i){}return!1},i.xdomainCheck=function(){return!1},t.transports.push("htmlfile")})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),(function(n,t,i){function r(){t.Transport.XHR.apply(this,arguments)}function u(){}n["xhr-polling"]=r,t.util.inherit(r,t.Transport.XHR),t.util.merge(r,t.Transport.XHR),r.prototype.name="xhr-polling",r.prototype.open=function(){var n=this;return t.Transport.XHR.prototype.open.call(n),!1},r.prototype.get=function(){function f(){if(this.readyState==4){this.onreadystatechange=u;if(this.status==200){n.onData(this.responseText);n.get()}else n.onClose()}}function r(){this.onload=u,this.onerror=u;n.onData(this.responseText);n.get()}function t(){n.onClose()}if(!this.open)return;var n=this;this.xhr=this.request(),i.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=r,this.xhr.onerror=t):this.xhr.onreadystatechange=f,this.xhr.send(null)},r.prototype.onClose=function(){t.Transport.XHR.prototype.onClose.call(this);if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=u;try{this.xhr.abort()}catch(n){}this.xhr=null}},r.prototype.ready=function(n,i){var r=this;t.util.defer(function(){i.call(r)})},t.transports.push("xhr-polling")})("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),(function(n,t,i){function r(){t.Transport["xhr-polling"].apply(this,arguments),this.index=t.j.length;var i=this;t.j.push(function(n){i._(n)})}var u=i.document&&"MozAppearance"in i.document.documentElement.style;n["jsonp-polling"]=r,t.util.inherit(r,t.Transport["xhr-polling"]),r.prototype.name="jsonp-polling",r.prototype.post=function(n){function o(){e(),r.socket.setBuffer(!1)}function e(){r.iframe&&r.form.removeChild(r.iframe);try{u=document.createElement('