chore: skip parse message when app not found

This commit is contained in:
Chareice 2025-01-01 10:21:16 +08:00
parent 2eacd69758
commit ed6d6f9f9a
No known key found for this signature in database

View File

@ -428,14 +428,17 @@ export class Gateway extends EventEmitter {
this.wsServer.on('message', async ({ client, message }) => { this.wsServer.on('message', async ({ client, message }) => {
const app = await AppSupervisor.getInstance().getApp(client.app); const app = await AppSupervisor.getInstance().getApp(client.app);
if (!app) {
return;
}
const parsedMessage = JSON.parse(message.toString()); const parsedMessage = JSON.parse(message.toString());
if (!parsedMessage.type) { if (!parsedMessage.type) {
return; return;
} }
// check app has event listener
if (!app.listenerCount(`ws:setTag`)) { if (!app.listenerCount(`ws:setTag`)) {
app.on('ws:setTag', ({ clientId, tagKey, tagValue }) => { app.on('ws:setTag', ({ clientId, tagKey, tagValue }) => {
this.wsServer.setClientTag(clientId, tagKey, tagValue); this.wsServer.setClientTag(clientId, tagKey, tagValue);