MCPcopy Index your code
hub / github.com/Effect-TS/effect / makeWebSocket

Function makeWebSocket

packages/platform/src/Socket.ts:376–389  ·  view source on GitHub ↗
(url: string | Effect.Effect<string>, options?: {
  readonly closeCodeIsError?: ((code: number) => boolean) | undefined
  readonly openTimeout?: DurationInput | undefined
  readonly protocols?: string | Array<string> | undefined
})

Source from the content-addressed store, hash-verified

374 * @category constructors
375 */
376export const makeWebSocket = (url: string | Effect.Effect<string>, options?: {
377 readonly closeCodeIsError?: ((code: number) => boolean) | undefined
378 readonly openTimeout?: DurationInput | undefined
379 readonly protocols?: string | Array<string> | undefined
380}): Effect.Effect<Socket, never, WebSocketConstructor> =>
381 fromWebSocket(
382 Effect.acquireRelease(
383 (typeof url === "string" ? Effect.succeed(url) : url).pipe(
384 Effect.flatMap((url) => Effect.map(WebSocketConstructor, (f) => f(url, options?.protocols)))
385 ),
386 (ws) => Effect.sync(() => ws.close(1000))
387 ),
388 options
389 )
390
391/**
392 * @since 1.0.0

Callers 3

layerWebSocketFunction · 0.85
makeWebSocketChannelFunction · 0.85
layerWebSocketFunction · 0.85

Calls 6

syncMethod · 0.80
fromWebSocketFunction · 0.70
pipeMethod · 0.65
mapMethod · 0.65
closeMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected