fix: case too many connection on websocket
Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
parent
a10dbbf26c
commit
c876847eff
3 changed files with 37 additions and 6 deletions
|
|
@ -9,6 +9,7 @@ import {
|
|||
recipeStreamMeta
|
||||
} from '../stores/recipeStore';
|
||||
import { buildOverviewFromServer } from '$lib/data/recipeService';
|
||||
import { auth } from '../client/firebase';
|
||||
|
||||
export const messages = writable<string[]>([]);
|
||||
|
||||
|
|
@ -118,7 +119,23 @@ const handlers: Record<string, (payload: any) => void> = {
|
|||
}
|
||||
}
|
||||
},
|
||||
stream_patch_update: (p) => {}
|
||||
stream_patch_update: (p) => {},
|
||||
notify: (p) => {
|
||||
let noti_level = p.level ?? 'INFO';
|
||||
let msg = p.msg ?? `Notify from ${p.from}`;
|
||||
let target = p.to;
|
||||
|
||||
if (target) {
|
||||
//
|
||||
let currentUsername = auth.currentUser?.displayName;
|
||||
if (currentUsername && currentUsername === target) {
|
||||
addNotification(`${noti_level}:${msg}`);
|
||||
}
|
||||
} else {
|
||||
// broadcast to all
|
||||
addNotification(`${noti_level}:${msg}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export function handleIncomingMessages(raw: string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue