Support WS connections on older browsers.
This commit is contained in:
parent
70551cebb7
commit
028313eb27
@ -74,10 +74,10 @@ class AwaitableWebSocket extends WebSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct an async WebSocket with await aWebSocket(url)
|
// Construct an async WebSocket with await aWebSocket(url) - supports relative URLs even with old browsers that don't
|
||||||
export default function aWebSocket(url, options = {}) {
|
export default function aWebSocket(url, options = {}) {
|
||||||
const { protocols, binaryType } = options
|
const { protocols, binaryType } = options
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
new AwaitableWebSocket(resolve, reject, url, protocols, binaryType)
|
new AwaitableWebSocket(resolve, reject, new URL(url, location.href), protocols, binaryType)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user