From eb60b0718e2ec21be2ec3536e361f07aa618bcec Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 18 Dec 2012 14:55:52 +0100 Subject: [PATCH] Fix indentation and some other improvements --- index.html | 64 +++++++++------------------------------------------- ws_server.js | 6 +++-- 2 files changed, 15 insertions(+), 55 deletions(-) diff --git a/index.html b/index.html index 90540d6..79b019d 100644 --- a/index.html +++ b/index.html @@ -1,59 +1,17 @@ - - WebSocket Client + + WebSocket Client Demo -

WebSocket Client

-

Open your web console to see the response!

-
- - - -
- - - - - +

WebSocket Client

+

Open the JavaScript console to see the response!

+
+ + + +
+ - \ No newline at end of file + diff --git a/ws_server.js b/ws_server.js index f6ca853..c25f552 100644 --- a/ws_server.js +++ b/ws_server.js @@ -18,7 +18,8 @@ wsServer = new WebSocketServer({ }); function isAllowedOrigin(origin) { - if (origin === 'http://localhost') { + valid_origins = ['http://localhost', '127.0.0.1']; + if (valid_origins.indexOf(origin) != -1) { console.log('Connection accepted from origin ' + origin); return true; } @@ -56,7 +57,8 @@ wsServer.on('request', function(request) { response = 'Keep typing, man. Keep typing.'; break; default: - response = "Hello. Uh... what am I supposed to do with '" + message.utf8Data + "'?"; + response = "Hello. Uh... what am I supposed to do with '" + + message.utf8Data + "'?"; } connection.sendUTF(response); }