| 114 | } |
| 115 | |
| 116 | private ingest(chunk: string): void { |
| 117 | this.buffer += chunk; |
| 118 | let split = this.buffer.indexOf('\n\n'); |
| 119 | while (split !== -1) { |
| 120 | const frame = this.buffer.slice(0, split); |
| 121 | this.buffer = this.buffer.slice(split + 2); |
| 122 | this.parse(frame); |
| 123 | split = this.buffer.indexOf('\n\n'); |
| 124 | } |
| 125 | // A heartbeat is its own frame and ends the same way, but node may deliver |
| 126 | // it alone; the loop above already handled it. |
| 127 | } |
| 128 | |
| 129 | private parse(frame: string): void { |
| 130 | let name = 'message'; |