Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

WebSocketFactory

Utilities for creating WebSocket instances across runtimes.

class WebSocketFactory {
private constructor();
static private detectEnvironment;
 
static createWebSocket(url: string | URL, protocols?: string | string[]): WebSocketLike;
static getWebSocketConstructor(): WebSocket;
static isWebSocketSupported(): boolean;
}

§Constructors

§
new WebSocketFactory() private
[src]

Static-only utility – prevent instantiation.

§Static Properties

§
detectEnvironment
[src]

§Static Methods

§
createWebSocket(url: string | URL, protocols?: string | string[]): WebSocketLike
[src]

Creates a WebSocket using the detected constructor.

@example
const socket = WebSocketFactory.createWebSocket('wss://realtime.supabase.co/socket')
§
getWebSocketConstructor(): WebSocket
[src]

Returns the best available WebSocket constructor for the current runtime.

@example
const WS = WebSocketFactory.getWebSocketConstructor()
const socket = new WS('wss://realtime.supabase.co/socket')
§
isWebSocketSupported(): boolean
[src]

Detects whether the runtime can establish WebSocket connections.

@example
if (!WebSocketFactory.isWebSocketSupported()) {
  console.warn('Falling back to long polling')
}