| 897 | * @since 4.0.0 |
| 898 | */ |
| 899 | export const makeWebSocket = (url: string | Effect.Effect<string>, options?: { |
| 900 | readonly openTimeout?: Duration.Input | undefined |
| 901 | readonly protocols?: string | Array<string> | undefined |
| 902 | readonly headers?: Readonly<Record<string, string>> | undefined |
| 903 | readonly highWaterMark?: number | undefined |
| 904 | }): Effect.Effect<Socket, never, WebSocketConstructor> => |
| 905 | WebSocketConstructor.use((makeWs) => |
| 906 | fromWebSocket( |
| 907 | Effect.acquireRelease( |
| 908 | (typeof url === "string" ? Effect.succeed(url) : url).pipe( |
| 909 | Effect.map((url) => |
| 910 | makeWs( |
| 911 | url, |
| 912 | options?.headers === undefined |
| 913 | ? options?.protocols |
| 914 | : { protocols: options.protocols, headers: options.headers } |
| 915 | ) |
| 916 | ) |
| 917 | ), |
| 918 | (ws) => Effect.sync(() => ws.close(1000)) |
| 919 | ), |
| 920 | options |
| 921 | ) |
| 922 | ) |
| 923 | |
| 924 | interface Pausable { |
| 925 | pause(): void |