| 49 | let latestSequence = -1 |
| 50 | |
| 51 | function* writeGen(response: typeof ProtocolResponse.Type) { |
| 52 | const data = encodeResponse(response) |
| 53 | if (response._tag !== "Changes" || data.byteLength <= constChunkSize) { |
| 54 | return yield* writeRaw(data) |
| 55 | } |
| 56 | const id = chunkId++ |
| 57 | for (const part of ChunkedMessage.split(id, data)) { |
| 58 | yield* writeRaw(encodeResponse(part)) |
| 59 | } |
| 60 | } |
| 61 | const write = (response: typeof ProtocolResponse.Type) => Effect.gen(() => writeGen(response)) |
| 62 | |
| 63 | yield* Effect.fork(write(new Hello({ remoteId }))) |