Skip to content

WSocket

molimawka edited this page May 9, 2022 · 2 revisions

WSocket

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)

Warning

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
Clone this wiki locally