BrowserSocket
Browser WebSocket layers for Effect sockets.
layerWebSocket creates a Socket.Socket connected to a WebSocket URL using
the browser WebSocket constructor. layerWebSocketConstructor provides
only the browser-backed constructor service for lower-level socket code.
Layers
layerWebSocket
Creates a Socket layer connected to the given URL using the browser WebSocket constructor.
When to use
Use when you need browser code to satisfy the platform socket service from a URL without wiring the browser constructor service separately.
Details
Delegates socket construction to Socket.makeWebSocket and provides the
browser-backed WebSocketConstructor service.
Gotchas
Browser WebSocket rules still control URL schemes, mixed-content blocking,
cookies, authentication, origin checks, subprotocols, and extensions. Every
close, whatever the code, fails the socket's reader with a SocketError.
See
- layerWebSocketConstructor for providing only the browser constructor service
Signature
declare function layerWebSocket(url: string, options?: { readonly highWaterMark?: number; readonly openTimeout?: Input; readonly protocols?: string | Array<string>;}): Layer<Socket>layerWebSocketConstructor
Layer that provides a WebSocketConstructor service backed by globalThis.WebSocket.
Signature
declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>