diff --git a/index.html b/index.html index e8d4963..eae5ba1 100644 --- a/index.html +++ b/index.html @@ -9,9 +9,9 @@ alert("Sorry, the build of your browser does not support WebSockets. Please use latest Chrome or Webkit nightly"); return; } - + ws = new WebSocket("ws://localhost:8080/"); - ws.onmessage = function(evt) { + ws.onmessage = function(evt) { data = eval("(" + evt.data + ")"); var p = $("
"); if($('#tweets div.tweet').size() > 15) { diff --git a/server.js b/server.js index 7743ffd..88481d5 100644 --- a/server.js +++ b/server.js @@ -30,7 +30,7 @@ var message = ""; request.addListener('response', function (response) { response.setEncoding("utf8"); - + response.addListener("data", function (chunk) { message += chunk; diff --git a/vendor/base64.js b/vendor/base64.js index c0053e0..1206594 100644 --- a/vendor/base64.js +++ b/vendor/base64.js @@ -3,7 +3,7 @@ * LastModified: Dec 25 1999 * This library is free. You can redistribute it and/or modify it. */ - + /* Modified by Dan Webb not to require Narwhal's binary library */ var encodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -50,8 +50,8 @@ exports.encode = function (str) { out.push(encodeChars.charCodeAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6))); out.push(encodeChars.charCodeAt(c3 & 0x3F)); } - - var str = ""; + + var str = ""; out.forEach(function(chr) { str += String.fromCharCode(chr) }); return str; }; diff --git a/vendor/ws.js b/vendor/ws.js index 747ee48..189ea56 100644 --- a/vendor/ws.js +++ b/vendor/ws.js @@ -38,8 +38,8 @@ var sys = require("sys"), 'origin': /^(.+)$/, }, handshakeTemplate75 = [ - 'HTTP/1.1 101 Web Socket Protocol Handshake', - 'Upgrade: WebSocket', + 'HTTP/1.1 101 Web Socket Protocol Handshake', + 'Upgrade: WebSocket', 'Connection: Upgrade', 'WebSocket-Origin: {origin}', 'WebSocket-Location: ws://{host}{resource}', @@ -70,13 +70,13 @@ exports.createServer = function (websocketListener, options) { var emitter = new process.EventEmitter(), handshaked = false, buffer = ""; - + function handle(data) { buffer += data; - + var chunks = buffer.split("\ufffd"), count = chunks.length - 1; // last is "" or a partial packet - + for(var i = 0; i < count; i++) { var chunk = chunks[i]; if(chunk[0] == "\u0000") { @@ -86,7 +86,7 @@ exports.createServer = function (websocketListener, options) { return; } } - + buffer = chunks[count]; } @@ -150,7 +150,7 @@ exports.createServer = function (websocketListener, options) { var hash = crypto.createHash("md5") , key1 = pack(parseInt(numkey1/spaces1)) , key2 = pack(parseInt(numkey2/spaces2)); - + hash.update(key1); hash.update(key2); hash.update(upgradeHead); @@ -196,23 +196,23 @@ exports.createServer = function (websocketListener, options) { }); emitter.remoteAddress = socket.remoteAddress; - + emitter.write = function (data) { try { socket.write('\u0000', 'binary'); socket.write(data, 'utf8'); socket.write('\uffff', 'binary'); - } catch(e) { - // Socket not open for writing, + } catch(e) { + // Socket not open for writing, // should get "close" event just before. socket.end(); } } - + emitter.end = function () { socket.end(); } - + websocketListener(emitter); // emits: "connect", "data", "close", provides: write(data), end() }); }