Guest User

Chrome

a guest
Mar 26th, 2016
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. // N2O CORE
  2.  
  3. var active = false,
  4. debug = false,
  5. protocol = window.location.protocol == 'https:' ? "wss://" : "ws://",
  6. querystring = window.location.pathname + window.location.search,
  7. host = null == transition.host ? window.location.hostname : transition.host,
  8. port = null == transition.port ? window.location.port : transition.port,
  9. protos = [ $client, $bert ];
  10.  
  11. function N2O_start() {
  12. ws = new bullet(protocol + host + (port==""?"":":"+port) + "/ws" + querystring);
  13. ws.onmessage = function (evt) { for (var i=0;i<protos.length;i++) { p = protos[i]; if (p.on(evt, p.do).status == "ok") return; } };
  14. ws.onopen = function() { if (!active) { console.log('Connect'); ws.send('N2O,'+transition.pid); active=true; } };
  15. ws.ondisconnect = function() { active = false; console.log('Disconnect'); };
  16. }
  17.  
  18. //WebSocket = undefined; // test XHR fallback
  19.  
  20. function qi(name) { return document.getElementById(name); }
  21. function qs(name) { return document.querySelector(name); }
  22. function qn(name) { return document.createElement(name); }
Add Comment
Please, Sign In to add comment