Skip to content

Commit c0189de

Browse files
author
pemrouz
committed
chore: parameterise transports
1 parent da698ae commit c0189de

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,15 @@ const headers = ripple => next => res => {
137137
}
138138

139139
const io = opts => {
140+
const transports = client
141+
&& document.currentScript
142+
&& document.currentScript.getAttribute('transports')
143+
&& document.currentScript.getAttribute('transports').split(',')
144+
|| undefined
145+
140146
const r = !client ? require('socket.io')(opts.server || opts)
141-
: window.io ? window.io({ transports: ['websocket', 'polling'] })
142-
: is.fn(require('socket.io-client')) ? require('socket.io-client')({ transports: ['websocket', 'polling'] })
147+
: window.io ? window.io({ transports })
148+
: is.fn(require('socket.io-client')) ? require('socket.io-client')({ transports })
143149
: { on: noop, emit: noop }
144150
r.use = r.use || noop
145151
return r

0 commit comments

Comments
 (0)