MCPcopy
hub / github.com/slackapi/node-slack-sdk / attemptAcknowledgePong

Method attemptAcknowledgePong

packages/rtm-api/src/KeepAlive.ts:239–255  ·  view source on GitHub ↗

* 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 })

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 2

debugMethod · 0.65

Tested by

no test coverage detected