Skip to content

Commit

Permalink
Merge pull request #51 from conversation/18108-remove-browserchannel
Browse files Browse the repository at this point in the history
Remove browserchannel as a dependency
  • Loading branch information
nickbrowne authored Oct 9, 2024
2 parents c332d6f + 9c46496 commit 460c694
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 555 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ If you need to re-compile the web client code, just run `npm install` again, or
Running tests
-------------

If you didn't already:

createdb sharejs_example

This project uses a pretty old version of nodeunit, but all tests can easily be run with:

npm run test
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"sockjs": ">= 0.3.1",
"socket.io": "2.5.0",
"socket.io-client": "2.4.0",
"browserchannel": "~1",
"ws": "0.4.32",
"connect": "<3.x",
"request": ">= 2.1.1",
Expand Down
17 changes: 6 additions & 11 deletions src/client/connection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@

if WEB?
types = exports.types
{BCSocket, SockJS, WebSocket} = window
if BCSocket
socketImpl = 'channel'
{SockJS, WebSocket} = window
if SockJS
socketImpl = 'sockjs'
else
if SockJS
socketImpl = 'sockjs'
else
socketImpl = 'websocket'
socketImpl = 'websocket'
else
types = require '../types'
{BCSocket} = require 'browserchannel'
Doc = require('./doc').Doc
WebSocket = require 'ws'
ReconnectingWebSocket = WebSocket
socketImpl = null

class Connection
Expand All @@ -44,10 +41,8 @@ class Connection
if host.match /^wss?:/ then socketImpl = 'websocket'

@socket = switch socketImpl
when 'channel' then new BCSocket(host, reconnect:true)
when 'sockjs' then new ReconnectingWebSocket(host, SockJS)
when 'websocket' then new ReconnectingWebSocket(host)
else new BCSocket(host, reconnect:true)
else new ReconnectingWebSocket(host)

@socket.onmessage = (msg) =>
msg = JSON.parse(msg.data) if socketImpl in ['sockjs', 'websocket']
Expand Down
12 changes: 0 additions & 12 deletions src/server/browserchannel.coffee

This file was deleted.

3 changes: 0 additions & 3 deletions src/server/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Model = require './model'
createDb = require './db'

rest = require './rest'
browserChannel = require './browserchannel'
sockjs = require './sockjs'
websocket = require './websocket'

Expand Down Expand Up @@ -54,8 +53,6 @@ create.attach = attach = (server, options, model = createModel(options)) ->
# done properly.
server.use rest(createAgent, options.rest or {}) if options.rest != null

browserChannel.attach(server, createAgent, options.browserChannel or {}) if options.browserChannel != null

if !(server instanceof http.Server)
server = http.createServer server

Expand Down
Loading

0 comments on commit 460c694

Please sign in to comment.