From bfcb8d6182ce9d5074453f08c3bb28912347d828 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Sun, 14 Jul 2013 07:36:23 -0400 Subject: [PATCH 001/149] Set Vary: Origin on CORS requests The Access-Control-Allow-Origin header is set depending on the request's Origin header. Although most requests also send Cache-Control headers with no-cache, the OPTIONS requests for CORS pre-flight requests do set cache headers. See http://www.w3.org/TR/cors/#resource-implementation --- src/trans-xhr.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/trans-xhr.coffee b/src/trans-xhr.coffee index 30b576ae..056782e0 100644 --- a/src/trans-xhr.coffee +++ b/src/trans-xhr.coffee @@ -62,6 +62,7 @@ exports.app = else origin = req.headers['origin'] res.setHeader('Access-Control-Allow-Origin', origin) + res.setHeader('Vary', 'Origin') headers = req.headers['access-control-request-headers'] if headers res.setHeader('Access-Control-Allow-Headers', headers) From 7ab5da088b4b7bfc3d4d5bde5ec129cad866cb32 Mon Sep 17 00:00:00 2001 From: Mike Brevoort Date: Fri, 20 Sep 2013 13:10:11 -0600 Subject: [PATCH 002/149] Renamed license file to standard LICENSE --- LICENSE-MIT-SockJS => LICENSE | 2 ++ 1 file changed, 2 insertions(+) rename LICENSE-MIT-SockJS => LICENSE (97%) diff --git a/LICENSE-MIT-SockJS b/LICENSE similarity index 97% rename from LICENSE-MIT-SockJS rename to LICENSE index a8971671..c619778a 100644 --- a/LICENSE-MIT-SockJS +++ b/LICENSE @@ -1,3 +1,5 @@ +The MIT License (MIT) + Copyright (C) 2011 VMware, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy From d6dacfbfae2f7309f0e081ced1de07775ec4bd29 Mon Sep 17 00:00:00 2001 From: Tony Date: Tue, 5 Nov 2013 08:19:15 -0600 Subject: [PATCH 003/149] Added example for hapi server framework. --- examples/hapi/html/index.html | 71 +++++++++++++++++++++++++++++++++++ examples/hapi/package.json | 8 ++++ examples/hapi/server.js | 33 ++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 examples/hapi/html/index.html create mode 100644 examples/hapi/package.json create mode 100644 examples/hapi/server.js diff --git a/examples/hapi/html/index.html b/examples/hapi/html/index.html new file mode 100644 index 00000000..a3ce2b40 --- /dev/null +++ b/examples/hapi/html/index.html @@ -0,0 +1,71 @@ + + + + + + +

SockJS Echo example

+ +
+
+
+
+ + + diff --git a/examples/hapi/package.json b/examples/hapi/package.json new file mode 100644 index 00000000..9121c5b0 --- /dev/null +++ b/examples/hapi/package.json @@ -0,0 +1,8 @@ +{ + "name": "sockjs-hapi", + "version": "0.0.0-unreleasable", + "dependencies": { + "hapi": "*", + "sockjs": "*" + } +} diff --git a/examples/hapi/server.js b/examples/hapi/server.js new file mode 100644 index 00000000..f684663b --- /dev/null +++ b/examples/hapi/server.js @@ -0,0 +1,33 @@ +/** + * Created by Tony on 11/1/13. + */ +var http = require('http'); +var sockjs = require('sockjs'); +var Hapi = require('hapi'); + +// 1. Echo sockjs server +var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"}; + +var sockjs_echo = sockjs.createServer(sockjs_opts); +sockjs_echo.on('connection', function(conn) { + conn.on('data', function(message) { + conn.write(message); + }); +}); + +// Create a server with a host and port +var hapi_server = Hapi.createServer('0.0.0.0', 9999); + +hapi_server.route({ + method: 'GET', + path: '/{path*}', + handler: { + directory: { path: './html', listing: false, index: true } + } +}); + +//hapi_server.listener is the http listener hapi uses +sockjs_echo.installHandlers(hapi_server.listener, {prefix:'/echo'}); + +console.log(' [*] Listening on 0.0.0.0:9999' ); +hapi_server.start(); From bbee9702e938ec13b225a5106a888371f5a7c91a Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Fri, 13 Dec 2013 19:27:00 +0100 Subject: [PATCH 004/149] Fixed vert.x repository link. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f373e24..08edb161 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ SockJS family: * [SockJS-node](https://github.com/sockjs/sockjs-node) Node.js server * [SockJS-erlang](https://github.com/sockjs/sockjs-erlang) Erlang server * [SockJS-tornado](https://github.com/MrJoes/sockjs-tornado) Python/Tornado server - * [vert.x](https://github.com/purplefox/vert.x) Java/vert.x server + * [vert.x](https://github.com/eclipse/vert.x) Java/vert.x server Work in progress: From e2e6ca6865fa37524c769acf0b572005c74d7c32 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sun, 29 Dec 2013 14:45:45 -0600 Subject: [PATCH 005/149] Upgrade Faye to 0.7.2. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 976304bf..18096467 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "https://github.com/sockjs/sockjs-node.git"}, "dependencies": { "node-uuid" : "1.3.3", - "faye-websocket" : "0.7.0" + "faye-websocket" : "0.7.2" }, "devDependencies": { "coffee-script" : "1.2.x" From 09863dcc6417b0bbe28eaaacf99c35ade0383191 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Mon, 5 May 2014 10:14:46 -0400 Subject: [PATCH 006/149] Fix license references --- COPYING | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/COPYING b/COPYING index a71ebfdf..3a33d194 100644 --- a/COPYING +++ b/COPYING @@ -3,4 +3,4 @@ Parts of the code are derived from various open source projects. For code derived from Socket.IO by Guillermo Rauch see https://github.com/LearnBoost/socket.io/tree/0.6.17#readme. -All other code is released on MIT license, see LICENSE-MIT-SockJS. +All other code is released on MIT license, see LICENSE. diff --git a/package.json b/package.json index 18096467..2c6d7e17 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name" : "sockjs", "author" : "Marek Majkowski", "version" : "0.3.8", + "license" : "MIT", "description" : "SockJS-node is a server counterpart of SockJS-client a JavaScript library that provides a WebSocket-like object in the browser. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.", "keywords" : ["websockets", "websocket"], "homepage" : "https://github.com/sockjs/sockjs-node", From 69749c0d300baa9ce088decd938738625cb25fdb Mon Sep 17 00:00:00 2001 From: David Glasser Date: Wed, 21 May 2014 18:47:58 -0700 Subject: [PATCH 007/149] Release 0.3.9 --- Changelog | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 309e4320..10e16635 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,10 @@ +0.3.9 +===== + + * #130 - Set Vary: Origin on CORS requests + * Upgrade Faye to 0.7.2 from 0.7.0 + + 0.3.8 ===== diff --git a/package.json b/package.json index 2c6d7e17..daed8ae6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "sockjs", "author" : "Marek Majkowski", - "version" : "0.3.8", + "version" : "0.3.9", "license" : "MIT", "description" : "SockJS-node is a server counterpart of SockJS-client a JavaScript library that provides a WebSocket-like object in the browser. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.", "keywords" : ["websockets", "websocket"], From b88f9eadf5f76f701c43fff86fd79be13156c5be Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Thu, 5 Jun 2014 22:58:41 -0700 Subject: [PATCH 008/149] Set heartbeat timer if needed, even if send_buffer Fixes #143 --- src/transport.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transport.coffee b/src/transport.coffee index dbdd1535..e9b97ec0 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -152,7 +152,7 @@ class Session return false tryFlush: -> - if not @flushToRecv(@recv) + if not @flushToRecv(@recv) or not @to_tref if @to_tref clearTimeout(@to_tref) x = => From 5112e90616e7c17400107e7a6dffac7f92cbbfe2 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Mon, 13 Oct 2014 20:23:44 -0400 Subject: [PATCH 009/149] Add CORS headers to eventsource --- src/trans-eventsource.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/trans-eventsource.coffee b/src/trans-eventsource.coffee index 170cc79f..16f81e3b 100644 --- a/src/trans-eventsource.coffee +++ b/src/trans-eventsource.coffee @@ -20,7 +20,18 @@ class EventSourceReceiver extends transport.ResponseReceiver exports.app = eventsource: (req, res) -> + if !req.headers['origin'] or req.headers['origin'] is 'null' + origin = '*' + else + origin = req.headers['origin'] res.setHeader('Content-Type', 'text/event-stream; charset=UTF-8') + res.setHeader('Access-Control-Allow-Origin', origin) + res.setHeader('Vary', 'Origin') + headers = req.headers['access-control-request-headers'] + if headers + res.setHeader('Access-Control-Allow-Headers', headers) + res.setHeader('Access-Control-Allow-Credentials', 'true') + res.writeHead(200) # Opera needs one more new line at the start. res.write('\r\n') From 4eaa6f59a73ee955fa8d405fb4af78db6cecec73 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Tue, 14 Oct 2014 11:01:51 -0400 Subject: [PATCH 010/149] Fix usage of Access-Control-Allow-Credentials --- src/trans-eventsource.coffee | 4 ++-- src/trans-xhr.coffee | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/trans-eventsource.coffee b/src/trans-eventsource.coffee index 16f81e3b..d56a441e 100644 --- a/src/trans-eventsource.coffee +++ b/src/trans-eventsource.coffee @@ -24,14 +24,14 @@ exports.app = origin = '*' else origin = req.headers['origin'] + res.setHeader('Access-Control-Allow-Credentials', 'true') res.setHeader('Content-Type', 'text/event-stream; charset=UTF-8') res.setHeader('Access-Control-Allow-Origin', origin) res.setHeader('Vary', 'Origin') headers = req.headers['access-control-request-headers'] if headers res.setHeader('Access-Control-Allow-Headers', headers) - res.setHeader('Access-Control-Allow-Credentials', 'true') - + res.writeHead(200) # Opera needs one more new line at the start. res.write('\r\n') diff --git a/src/trans-xhr.coffee b/src/trans-xhr.coffee index 056782e0..793f7235 100644 --- a/src/trans-xhr.coffee +++ b/src/trans-xhr.coffee @@ -61,12 +61,12 @@ exports.app = origin = '*' else origin = req.headers['origin'] + res.setHeader('Access-Control-Allow-Credentials', 'true') res.setHeader('Access-Control-Allow-Origin', origin) res.setHeader('Vary', 'Origin') headers = req.headers['access-control-request-headers'] if headers res.setHeader('Access-Control-Allow-Headers', headers) - res.setHeader('Access-Control-Allow-Credentials', 'true') return content xhr_poll: (req, res, _, next_filter) -> From d3b6c0626761f18c354255df68d51fcbeed90286 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Tue, 14 Oct 2014 11:06:17 -0400 Subject: [PATCH 011/149] Remove charset from even source. Spec says it is always utf-8. --- src/trans-eventsource.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trans-eventsource.coffee b/src/trans-eventsource.coffee index d56a441e..d1d81145 100644 --- a/src/trans-eventsource.coffee +++ b/src/trans-eventsource.coffee @@ -25,7 +25,7 @@ exports.app = else origin = req.headers['origin'] res.setHeader('Access-Control-Allow-Credentials', 'true') - res.setHeader('Content-Type', 'text/event-stream; charset=UTF-8') + res.setHeader('Content-Type', 'text/event-stream') res.setHeader('Access-Control-Allow-Origin', origin) res.setHeader('Vary', 'Origin') headers = req.headers['access-control-request-headers'] From 86812668d7d7b6a897a11777a3b176461d7c6dc8 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Wed, 22 Oct 2014 00:50:32 -0400 Subject: [PATCH 012/149] Fix #96 remove rbytes --- README.md | 6 ------ src/utils.coffee | 15 +++------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 08edb161..1eb9683c 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,6 @@ To install `sockjs-node` run: npm install sockjs -For additional security (true random numbers) you might want to -install `rbytes` package - SockJS will use it if available: - - npm install rbytes - - A simplified echo SockJS server could look more or less like: ```javascript diff --git a/src/utils.coffee b/src/utils.coffee index f195840a..d92c4f77 100644 --- a/src/utils.coffee +++ b/src/utils.coffee @@ -6,10 +6,6 @@ crypto = require('crypto') -try - rbytes = require('rbytes') -catch x - exports.array_intersection = array_intersection = (arr_a, arr_b) -> r = [] for a in arr_a @@ -117,11 +113,6 @@ exports.parseCookie = (cookie_header) -> return cookies exports.random32 = () -> - if rbytes - foo = rbytes.randomBytes(4) - v = [foo[0], foo[1], foo[2], foo[3]] - else - foo = -> Math.floor(Math.random()*256) - v = [foo(), foo(), foo(), foo()] - - return v[0] + (v[1]*256 ) + (v[2]*256*256) + (v[3]*256*256*256) + foo = crypto.randomBytes(4) + v = [foo[0], foo[1], foo[2], foo[3]] + return v[0] + (v[1]*256) + (v[2]*256*256) + (v[3]*256*256*256) From 4df6ed77b5924cbb677df2adebf38f2b91ebc4e2 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Wed, 22 Oct 2014 01:14:20 -0400 Subject: [PATCH 013/149] Fix #83 Update prefix docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1eb9683c..4999cbca 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Where `options` is a hash which can contain: browser - it makes sense to reuse the sockjs url you're using in normally. -
prefix (string)
+
prefix (string regex)
A url prefix for the server. All http requests which paths begins with selected prefix will be handled by SockJS. All other requests will be passed through, to previously registered handlers.
From b6aca87a6d84a83ff3fdcda9b240a89105ba454e Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Wed, 22 Oct 2014 12:28:39 -0400 Subject: [PATCH 014/149] Fix #163 add protection from SWF JSONP exploit --- src/trans-jsonp.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/trans-jsonp.coffee b/src/trans-jsonp.coffee index 7aad58ec..ef90aa92 100644 --- a/src/trans-jsonp.coffee +++ b/src/trans-jsonp.coffee @@ -17,7 +17,8 @@ class JsonpReceiver extends transport.ResponseReceiver # Yes, JSONed twice, there isn't a a better way, we must pass # a string back, and the script, will be evaled() by the # browser. - super(@callback + "(" + JSON.stringify(payload) + ");\r\n") + # prepend comment to avoid SWF exploit #163 + super("/**/" + @callback + "(" + JSON.stringify(payload) + ");\r\n") exports.app = @@ -29,12 +30,14 @@ exports.app = } callback = if 'c' of req.query then req.query['c'] else req.query['callback'] - if /[^a-zA-Z0-9-_.]/.test(callback) + if /[^a-zA-Z0-9-_.]/.test(callback) or callback.length > 32 throw { status: 500 message: 'invalid "callback" parameter' } + # protect against SWF JSONP exploit - #163 + res.setHeader('X-Content-Type-Options', 'nosniff') res.setHeader('Content-Type', 'application/javascript; charset=UTF-8') res.writeHead(200) From 96ae8ed65b61b80fb0623717ace5649126fd49dd Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Wed, 22 Oct 2014 13:37:21 -0400 Subject: [PATCH 015/149] Fix #104 get rid of unused parameters --- src/trans-websocket.coffee | 2 +- src/transport.coffee | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/trans-websocket.coffee b/src/trans-websocket.coffee index 37b8d6b5..fbde4941 100644 --- a/src/trans-websocket.coffee +++ b/src/trans-websocket.coffee @@ -73,7 +73,7 @@ class WebSocketReceiver extends transport.GenericReceiver try message = JSON.parse(payload) catch x - return @didClose(1002, 'Broken framing.') + return @session.close(1002, 'Broken framing.') if payload[0] is '[' for msg in message @session.didMessage(msg) diff --git a/src/transport.coffee b/src/transport.coffee index e9b97ec0..f3e7c7ab 100644 --- a/src/transport.coffee +++ b/src/transport.coffee @@ -237,7 +237,7 @@ class GenericReceiver @setUp(@thingy) setUp: -> - @thingy_end_cb = () => @didAbort(1006, "Connection closed") + @thingy_end_cb = () => @didAbort() @thingy.addListener('close', @thingy_end_cb) @thingy.addListener('end', @thingy_end_cb) @@ -246,18 +246,18 @@ class GenericReceiver @thingy.removeListener('end', @thingy_end_cb) @thingy_end_cb = null - didAbort: (status, reason) -> + didAbort: -> session = @session - @didClose(status, reason) + @didClose() if session session.didTimeout() - didClose: (status, reason) -> + didClose: -> if @thingy @tearDown(@thingy) @thingy = null if @session - @session.unregister(status, reason) + @session.unregister() doSendBulk: (messages) -> q_msgs = for m in messages From 26cf7dfbd9937378d24a962d77f25f6b79bc8cfa Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Wed, 22 Oct 2014 13:46:50 -0400 Subject: [PATCH 016/149] Fix #106 Update sockjs CDN urls --- README.md | 4 ++-- examples/echo/index.html | 2 +- examples/echo/server.js | 2 +- examples/express-3.x/index.html | 2 +- examples/express-3.x/server.js | 2 +- examples/express/index.html | 2 +- examples/express/server.js | 2 +- examples/hapi/html/index.html | 2 +- examples/hapi/server.js | 2 +- examples/multiplex/index.html | 2 +- examples/multiplex/server.js | 2 +- src/sockjs.coffee | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4999cbca..88bbf066 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ A simplified echo SockJS server could look more or less like: var http = require('http'); var sockjs = require('sockjs'); -var echo = sockjs.createServer(); +var echo = sockjs.createServer({ sockjs_url: 'http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js' }); echo.on('connection', function(conn) { conn.on('data', function(message) { conn.write(message); @@ -110,7 +110,7 @@ Where `options` is a hash which can contain: domain local to the SockJS server. This iframe also does need to load SockJS javascript client library, and this option lets you specify its url (if you're unsure, point it to - + the latest minified SockJS client release, this is the default). You must explicitly specify this url on the server side for security reasons - we don't want the possibility of running any foreign diff --git a/examples/echo/index.html b/examples/echo/index.html index a3ce2b40..c5c5fccf 100644 --- a/examples/echo/index.html +++ b/examples/echo/index.html @@ -1,7 +1,7 @@ - + + +

SockJS Express example

+ +
+
+
+
+ + + diff --git a/examples/koa/package.json b/examples/koa/package.json new file mode 100644 index 00000000..8ee004f0 --- /dev/null +++ b/examples/koa/package.json @@ -0,0 +1,8 @@ +{ + "name": "sockjs-koa", + "version": "0.0.0-unreleasable", + "dependencies": { + "koa": "^0.21.0", + "sockjs": "*" + } +} diff --git a/examples/koa/server.js b/examples/koa/server.js new file mode 100644 index 00000000..1ad623be --- /dev/null +++ b/examples/koa/server.js @@ -0,0 +1,29 @@ +var koa = require('koa'); +var sockjs = require('sockjs'); +var http = require('http'); +var fs = require('fs'); +var path = require('path'); + +// 1. Echo sockjs server +var sockjs_opts = {sockjs_url: "http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"}; +var sockjs_echo = sockjs.createServer(sockjs_opts); +sockjs_echo.on('connection', function(conn) { + conn.on('data', function(message) { + conn.write(message); + }); +}); + +// 2. koa server +var app = koa(); + +app.use(function *() { + var filePath = __dirname + '/index.html'; + this.type = path.extname(filePath); + this.body = fs.createReadStream(filePath); +}); + +var server = http.createServer(app.callback()); +sockjs_echo.installHandlers(server, {prefix:'/echo'}); + +server.listen(9999, '0.0.0.0'); +console.log(' [*] Listening on 0.0.0.0:9999' ); From d4385b584682c5f0ae8ccb082678f4fbea90f7c7 Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Tue, 21 Jul 2015 22:11:01 -0700 Subject: [PATCH 042/149] Fix #182 update sockjs-client version in docs and example to 1.0.1 --- README.md | 4 ++-- examples/echo/index.html | 2 +- examples/echo/server.js | 2 +- examples/express-3.x/index.html | 2 +- examples/express-3.x/server.js | 2 +- examples/express/index.html | 2 +- examples/express/server.js | 2 +- examples/hapi/html/index.html | 2 +- examples/hapi/server.js | 2 +- examples/multiplex/index.html | 2 +- examples/multiplex/server.js | 2 +- src/sockjs.coffee | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3ae3870b..b1353f0b 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ A simplified echo SockJS server could look more or less like: var http = require('http'); var sockjs = require('sockjs'); -var echo = sockjs.createServer({ sockjs_url: 'http://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js' }); +var echo = sockjs.createServer({ sockjs_url: 'http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js' }); echo.on('connection', function(conn) { conn.on('data', function(message) { conn.write(message); @@ -99,7 +99,7 @@ Where `options` is a hash which can contain: domain local to the SockJS server. This iframe also does need to load SockJS javascript client library, and this option lets you specify its url (if you're unsure, point it to - + the latest minified SockJS client release, this is the default). You must explicitly specify this url on the server side for security reasons - we don't want the possibility of running any foreign diff --git a/examples/echo/index.html b/examples/echo/index.html index c5c5fccf..41734548 100644 --- a/examples/echo/index.html +++ b/examples/echo/index.html @@ -1,7 +1,7 @@ - + - -

SockJS Express example

- -
-
-
-
- - - diff --git a/examples/express-3.x/package.json b/examples/express-3.x/package.json deleted file mode 100644 index 9c6a19f3..00000000 --- a/examples/express-3.x/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "sockjs-express", - "version": "0.0.0-unreleasable", - "dependencies": { - "express": "~3*", - "sockjs": "*" - } -} diff --git a/examples/express-3.x/server.js b/examples/express-3.x/server.js deleted file mode 100644 index 47484fcb..00000000 --- a/examples/express-3.x/server.js +++ /dev/null @@ -1,26 +0,0 @@ -var express = require('express'); -var sockjs = require('sockjs'); -var http = require('http'); - -// 1. Echo sockjs server -var sockjs_opts = {sockjs_url: "http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js"}; - -var sockjs_echo = sockjs.createServer(sockjs_opts); -sockjs_echo.on('connection', function(conn) { - conn.on('data', function(message) { - conn.write(message); - }); -}); - -// 2. Express server -var app = express(); /* express.createServer will not work here */ -var server = http.createServer(app); - -sockjs_echo.installHandlers(server, {prefix:'/echo'}); - -console.log(' [*] Listening on 0.0.0.0:9999' ); -server.listen(9999, '0.0.0.0'); - -app.get('/', function (req, res) { - res.sendfile(__dirname + '/index.html'); -}); diff --git a/examples/express/index.html b/examples/express/index.html index 050ce550..c10e1282 100644 --- a/examples/express/index.html +++ b/examples/express/index.html @@ -1,7 +1,7 @@ - +