Skip to content

Commit

Permalink
chore: parameterise transports
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed Sep 15, 2016
1 parent da698ae commit c0189de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,15 @@ const headers = ripple => next => res => {
}

const io = opts => {
const transports = client
&& document.currentScript
&& document.currentScript.getAttribute('transports')
&& document.currentScript.getAttribute('transports').split(',')
|| undefined

const r = !client ? require('socket.io')(opts.server || opts)
: window.io ? window.io({ transports: ['websocket', 'polling'] })
: is.fn(require('socket.io-client')) ? require('socket.io-client')({ transports: ['websocket', 'polling'] })
: window.io ? window.io({ transports })
: is.fn(require('socket.io-client')) ? require('socket.io-client')({ transports })
: { on: noop, emit: noop }
r.use = r.use || noop
return r
Expand Down

0 comments on commit c0189de

Please sign in to comment.