-
Notifications
You must be signed in to change notification settings - Fork 0
WSocket
molimawka edited this page May 9, 2022
·
2 revisions
const wsocket = new WSocket(url: string | URL, protocols?: string | string[])
Or if instance is already created can use this
const wsocket = WSocket.get(url: string | URL)
URL is unqiue value Example
const wsocket1 = new WSocket("ws://example.com/")
const wsocket2 = new WSocket("ws://example.com/")
console.log(wsocket1 == wsocket2) // true
If you want to create 2 connections to same url randomize url
const wsocket1 = new WSocket("ws://example.com/?rndv=5")
const wsocket2 = new WSocket("ws://example.com/?rndv=5313")
console.log(wsocket1 == wsocket2) // false