* Attaches handlers for the given transport. * * @param {Transport} transport * @private
(transport: Transport)
| 245 | * @private |
| 246 | */ |
| 247 | private setTransport(transport: Transport) { |
| 248 | const onError = this.onError.bind(this); |
| 249 | const onReady = () => this.flush(); |
| 250 | const onPacket = this.onPacket.bind(this); |
| 251 | const onDrain = this.onDrain.bind(this); |
| 252 | const onClose = this.onClose.bind(this, class="st">"transport close"); |
| 253 | |
| 254 | this.transport = transport; |
| 255 | this.transport.once(class="st">"error", onError); |
| 256 | this.transport.on(class="st">"ready", onReady); |
| 257 | this.transport.on(class="st">"packet", onPacket); |
| 258 | this.transport.on(class="st">"drain", onDrain); |
| 259 | this.transport.once(class="st">"close", onClose); |
| 260 | |
| 261 | this.cleanupFn.push(function () { |
| 262 | transport.removeListener(class="st">"error", onError); |
| 263 | transport.removeListener(class="st">"ready", onReady); |
| 264 | transport.removeListener(class="st">"packet", onPacket); |
| 265 | transport.removeListener(class="st">"drain", onDrain); |
| 266 | transport.removeListener(class="st">"close", onClose); |
| 267 | }); |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Upon transport class="st">"drain" event |
no test coverage detected