MCPcopy Create free account
hub / github.com/apache/maka / wire

Method wire

packages/runtime/src/bots/feishu-bridge.ts:176–205  ·  view source on GitHub ↗
(channel: LarkChannel, appId: string)

Source from the content-addressed store, hash-verified

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 {

Callers 1

startMethod · 0.95

Calls 6

markConnectedMethod · 0.95
generalizedErrorMessageFunction · 0.90
feishuMessageToEventFunction · 0.85
onMethod · 0.80
pushMethod · 0.65
nowMethod · 0.65

Tested by

no test coverage detected