From f73332f5c0cd5d539c07e863f12fd791bbec3d35 Mon Sep 17 00:00:00 2001 From: nickbrowne Date: Wed, 12 Feb 2025 10:00:43 +1100 Subject: [PATCH] Remove remnants of socket.io We had actually stopped using it a while back, so this doesn't change much other than removing the packages and cleaning up some now irrelevant comments. --- bin/exampleserver | 2 +- bin/sharejs | 2 +- package.json | 2 -- src/client/doc.coffee | 3 +-- src/client/index.coffee | 3 --- src/server/useragent.coffee | 5 ----- test/helpers/webclient.coffee | 1 - test/integration.coffee | 3 +-- test/server.coffee | 2 +- test/sockjs.coffee | 4 ---- tests.coffee | 4 +++- 11 files changed, 8 insertions(+), 23 deletions(-) diff --git a/bin/exampleserver b/bin/exampleserver index 14890b2..f5dfc7d 100755 --- a/bin/exampleserver +++ b/bin/exampleserver @@ -42,7 +42,7 @@ console.log("Options: ", options); var port = argv.p; -// Attach the sharejs REST and Socket.io interfaces to the server +// Attach the sharejs REST and websocket interfaces to the server var server = sharejs.server.attach(app, options); app.get('/pad/?', function(req, res, next) { diff --git a/bin/sharejs b/bin/sharejs index 8f6d09e..d290095 100755 --- a/bin/sharejs +++ b/bin/sharejs @@ -17,7 +17,7 @@ options = require('./options') || {}; console.log("ShareJS server v" + sharejs.version); -// Attach the sharejs REST and Socket.io interfaces to the server +// Attach the sharejs REST and websocket interfaces to the server var server = sharejs.server.attach(app, options); var port = options.port || 8000; diff --git a/package.json b/package.json index 1603910..aa8db09 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,6 @@ "pg": "7.4.0", "pg-native": "3.0.1", "sockjs": ">= 0.3.1", - "socket.io": "2.5.0", - "socket.io-client": "2.4.0", "ws": "5.2.4", "request": ">= 2.1.1", "coffee-script": "1.7.0", diff --git a/src/client/doc.coffee b/src/client/doc.coffee index 39f3399..fc90f6e 100644 --- a/src/client/doc.coffee +++ b/src/client/doc.coffee @@ -231,8 +231,7 @@ class Doc # We got a new op from the server. # msg is {doc:, op:, v:} - # There is a bug in socket.io (produced on firefox 3.6) which causes messages - # to be duplicated sometimes. + # There is a bug which causes messages to be duplicated sometimes. # We'll just silently drop subsequent messages. return if msg.v < @version diff --git a/src/client/index.coffee b/src/client/index.coffee index 9d2361d..614a325 100644 --- a/src/client/index.coffee +++ b/src/client/index.coffee @@ -4,9 +4,6 @@ # It works from both a node.js context and a web context (though in the latter case, # it needs to be compiled to work.) # -# It should become a little nicer once I start using more of the new RPC features added -# in socket.io 0.7. -# # Note that anything declared in the global scope here is shared with other files # built by closure. Be careful what you put in this namespace. diff --git a/src/server/useragent.coffee b/src/server/useragent.coffee index 6f98d18..f2fe765 100644 --- a/src/server/useragent.coffee +++ b/src/server/useragent.coffee @@ -28,11 +28,6 @@ module.exports = (model, options) -> # Should be manually set by the auth function. @name = null - # We have access to these with socket.io, but I'm not sure we can support - # these properties on the REST API or sockjs, etc. - #xdomain: data.xdomain - #secure: data.secure - # This is a helper method which wraps auth() above. It creates the action and calls # auth. If authentication succeeds, acceptCallback() is called if it exists. otherwise # userCallback(true) is called. diff --git a/test/helpers/webclient.coffee b/test/helpers/webclient.coffee index dd829f7..e1ff4ad 100644 --- a/test/helpers/webclient.coffee +++ b/test/helpers/webclient.coffee @@ -10,7 +10,6 @@ TEST_UNCOMPRESSED = false fs = require 'fs' window = {} -window.io = require 'socket.io-client' for script in ['share', 'json'] script = "#{script}.uncompressed" if TEST_UNCOMPRESSED diff --git a/test/integration.coffee b/test/integration.coffee index b176e0e..5e3a483 100644 --- a/test/integration.coffee +++ b/test/integration.coffee @@ -105,8 +105,7 @@ genTests = (client, dbType) -> testCase # This test consumes open file handles. If you want to set # it higher, you need to run: # % ulimit -n 8096 - # to increase the OS limit. This happens because of a bug in - # socket.io. + # to increase the OS limit. if num < 30 nowOrLater more else diff --git a/test/server.coffee b/test/server.coffee index b31c51e..8c627c6 100644 --- a/test/server.coffee +++ b/test/server.coffee @@ -22,6 +22,6 @@ testRunning = (url, port, callback) -> post.end '{"type":"simple"}' - # Also, open the DB using socket.io and make a document + # Open the DB and make a document client = new client.Connection 'localhost', port, url client. diff --git a/test/sockjs.coffee b/test/sockjs.coffee index 1828e97..0023efb 100644 --- a/test/sockjs.coffee +++ b/test/sockjs.coffee @@ -379,10 +379,6 @@ module.exports = testCase test.strictEqual typeof agent.headers, 'object' - # I can't edit the headers using socket.io-agent's API. I'd test the default headers in this - # object, but the default XHR headers aren't part of socket.io's API, so they could change between - # versions and break the test. - # TODO - Get SockJS to put user-agent header in the connection test.strictEqual agent.headers['user-agent'], undefined #'node.js' diff --git a/tests.coffee b/tests.coffee index add1ef3..6872ee9 100644 --- a/tests.coffee +++ b/tests.coffee @@ -36,8 +36,10 @@ modules = [ exports[module] = require "./test/#{module}" for module in modules -# This is a little hack to get around the lack of cleanup done by socket.io. It should terminate +# This is a little hack to get around the lack of cleanup done by sockjs. It should terminate # the node.js process 2 seconds after all the tests are complete. +# +# When sockjs is removed, this can be removed as well exports.cleanup = (test) -> test.done() setTimeout (-> process.exit(0)), 2000