(sock, data)
| 194 | sock.data = { ...newConnState(), writeBuf: [] } |
| 195 | }, |
| 196 | data(sock, data) { |
| 197 | const st = sock.data |
| 198 | const adapter: ClientSocket = { |
| 199 | write: payload => { |
| 200 | const bytes = |
| 201 | typeof payload === 'string' |
| 202 | ? Buffer.from(payload, 'utf8') |
| 203 | : payload |
| 204 | if (st.writeBuf.length > 0) { |
| 205 | st.writeBuf.push(bytes) |
| 206 | return |
| 207 | } |
| 208 | const n = sock.write(bytes) |
| 209 | if (n < bytes.length) st.writeBuf.push(bytes.subarray(n)) |
| 210 | }, |
| 211 | end: () => sock.end(), |
| 212 | } |
| 213 | handleData(adapter, st, data, wsUrl, authHeader, wsAuthHeader) |
| 214 | }, |
| 215 | drain(sock) { |
| 216 | const st = sock.data |
| 217 | while (st.writeBuf.length > 0) { |
nothing calls this directly
no test coverage detected