(chunk: Uint8Array | string | CloseEvent)
| 500 | : handler(new Uint8Array(data)), opts) |
| 501 | |
| 502 | const write = (chunk: Uint8Array | string | CloseEvent) => |
| 503 | latch.whenOpen(Effect.sync(() => { |
| 504 | const ws = currentWS! |
| 505 | if (isCloseEvent(chunk)) { |
| 506 | ws.close(chunk.code, chunk.reason) |
| 507 | } else { |
| 508 | ws.send(chunk) |
| 509 | } |
| 510 | })) |
| 511 | const writer = Effect.succeed(write) |
| 512 | |
| 513 | return Effect.succeed(Socket.of({ |