| 147 | } |
| 148 | |
| 149 | const rawNetClient = async (port: number): Promise<RawClient> => { |
| 150 | const conn = Net.createConnection({ host: "127.0.0.1", port }) |
| 151 | await once(conn, "connect") |
| 152 | conn.setNoDelay(true) |
| 153 | const counter = makeReadCounter() |
| 154 | conn.on("data", (chunk: Buffer) => counter.push(chunk.length)) |
| 155 | return { |
| 156 | write(frames) { |
| 157 | conn.cork() |
| 158 | let flushed = true |
| 159 | for (const frame of frames) flushed = conn.write(frame) |
| 160 | conn.uncork() |
| 161 | return flushed ? Promise.resolve() : once(conn, "drain").then(() => {}) |
| 162 | }, |
| 163 | read: counter.read, |
| 164 | close: () => conn.destroy() |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | const rawWebSocketClient = async (url: string): Promise<RawClient> => { |
| 169 | const ws = new WebSocket(url) |