fix(feishu): WSClient appId + EventDispatcher pattern
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
042e49988c
commit
bbcf1d742d
|
|
@ -127,12 +127,12 @@ export class FeishuRouterService implements OnModuleInit, OnModuleDestroy {
|
||||||
|
|
||||||
// WebSocket long-connection client — SDK handles auth, reconnect, ping/pong, ACK
|
// WebSocket long-connection client — SDK handles auth, reconnect, ping/pong, ACK
|
||||||
this.wsClient = new lark.WSClient({
|
this.wsClient = new lark.WSClient({
|
||||||
appID: this.appId,
|
appId: this.appId,
|
||||||
appSecret: this.appSecret,
|
appSecret: this.appSecret,
|
||||||
loggerLevel: lark.LoggerLevel.warn,
|
loggerLevel: lark.LoggerLevel.warn,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wsClient.start({
|
const dispatcher = new lark.EventDispatcher({}).register({
|
||||||
'im.message.receive_v1': async (data: any) => {
|
'im.message.receive_v1': async (data: any) => {
|
||||||
try {
|
try {
|
||||||
await this.handleIncomingEvent(data);
|
await this.handleIncomingEvent(data);
|
||||||
|
|
@ -142,6 +142,8 @@ export class FeishuRouterService implements OnModuleInit, OnModuleDestroy {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.wsClient.start({ eventDispatcher: dispatcher });
|
||||||
|
|
||||||
this.cleanupTimer = setInterval(() => this.periodicCleanup(), CLEANUP_INTERVAL_MS);
|
this.cleanupTimer = setInterval(() => this.periodicCleanup(), CLEANUP_INTERVAL_MS);
|
||||||
if (this.cleanupTimer.unref) this.cleanupTimer.unref();
|
if (this.cleanupTimer.unref) this.cleanupTimer.unref();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue