(channel: LarkChannel, appId: string)
| 174 | } |
| 175 | |
| 176 | private wire(channel: LarkChannel, appId: string): void { |
| 177 | this.unsubscribe.push( |
| 178 | channel.on('message', (message) => { |
| 179 | const receivedAt = Date.now(); |
| 180 | const event = feishuMessageToEvent(message, receivedAt, this.settings.allowedUserIds); |
| 181 | if (!event || this.channel !== channel) return; |
| 182 | this.lastEventAt = receivedAt; |
| 183 | this.readiness = 'operational'; |
| 184 | this.reason = undefined; |
| 185 | this.emitIncomingMessage(event); |
| 186 | this.emitStatusChange(); |
| 187 | }), |
| 188 | channel.on('error', (error) => { |
| 189 | if (this.channel !== channel || this.explicitlyStopped) return; |
| 190 | this.reason = generalizedErrorMessage(error); |
| 191 | this.readiness = this.readiness === 'operational' ? 'degraded' : 'configured'; |
| 192 | this.emitStatusChange(); |
| 193 | }), |
| 194 | channel.on('reconnecting', () => { |
| 195 | if (this.channel !== channel || this.explicitlyStopped) return; |
| 196 | this.running = false; |
| 197 | this.reason = 'reconnecting'; |
| 198 | this.emitStatusChange(); |
| 199 | }), |
| 200 | channel.on('reconnected', () => { |
| 201 | if (this.channel !== channel || this.explicitlyStopped) return; |
| 202 | this.markConnected(channel, appId); |
| 203 | }), |
| 204 | ); |
| 205 | } |
| 206 | |
| 207 | /** Shared connected-state transition for the initial handshake and reconnects. */ |
| 208 | private markConnected(channel: LarkChannel, appId: string): void { |
no test coverage detected