* Determines if a giving incoming event can be treated as an acknowledgement for the outstanding ping, and then * clears the ping if so. * @param event incoming slack event
(_type: string, event: { [key: string]: unknown })
| 237 | * @param event incoming slack event |
| 238 | */ |
| 239 | private attemptAcknowledgePong(_type: string, event: { [key: string]: unknown }): void { |
| 240 | if (this.client === undefined) { |
| 241 | const error = new Error('no client found'); |
| 242 | (error as CodedError).code = ErrorCode.KeepAliveInconsistentState; |
| 243 | throw error; |
| 244 | } |
| 245 | |
| 246 | if (this.lastPing !== undefined && event.reply_to !== undefined && (event.reply_to as number) >= this.lastPing) { |
| 247 | // this message is a reply that acks the previous ping, clear the last ping |
| 248 | this.logger.debug('received pong, clearing pong timer'); |
| 249 | delete this.lastPing; |
| 250 | |
| 251 | // signal that this pong is done being handled |
| 252 | this.clearPreviousPongTimer(); |
| 253 | this.client.off('slack_event', this.attemptAcknowledgePong); |
| 254 | } |
| 255 | } |
| 256 | } |
nothing calls this directly
no test coverage detected