(url: string | Effect.Effect<string>, options?: {
readonly closeCodeIsError?: ((code: number) => boolean) | undefined
readonly openTimeout?: DurationInput | undefined
readonly protocols?: string | Array<string> | undefined
})
| 374 | * @category constructors |
| 375 | */ |
| 376 | export 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 |
no test coverage detected