diff --git a/src/backend/Components/PubSub/PubSub.ts b/src/backend/Components/PubSub/PubSub.ts index af68bc9..3764086 100644 --- a/src/backend/Components/PubSub/PubSub.ts +++ b/src/backend/Components/PubSub/PubSub.ts @@ -23,15 +23,15 @@ implements RPCExporter{ } ] - publish = ( topic: string, msg: UpdateType ) => { + publish = async (topic: string, msg: UpdateType ) => { if(!this.subs[topic]) this.subs[topic] = {} - Object.entries(this.subs[topic]).forEach(([uuid, callback]:[string, Function]) => { + await Promise.all(Object.entries(this.subs[topic]).map(async ([uuid, callback]:[string, Function]) => { try{ - callback(msg) + await callback(msg) }catch(e){ delete this.subs[topic][uuid] } - }) + })) } subscribe = async (topic:string, callback:(p:UpdateType)=>any) : Promise> => { diff --git a/src/backend/Components/Shoutbox/Shoutbox.ts b/src/backend/Components/Shoutbox/Shoutbox.ts index f14a74b..904b19d 100644 --- a/src/backend/Components/Shoutbox/Shoutbox.ts +++ b/src/backend/Components/Shoutbox/Shoutbox.ts @@ -38,14 +38,14 @@ implements FrontworkComponent, IShoutbox{ this.log.push(msg) } - private broadcast = (uuid:string, msg: ShoutMessage) => { - Object.values(this.subs).forEach((cb:any) => { + private broadcast = async (uuid:string, msg: ShoutMessage) => { + await Promise.all(Object.values(this.subs).map(async (callback:any) => { try{ - cb(msg) + await callback(msg) }catch(e){ - this.unsubscribe(uuid) + delete this.subs[uuid] } - }) + })) } getFeed = async () : Promise => { diff --git a/src/frontend/src/app/frontcraft/pages/pages-layout.component.ts b/src/frontend/src/app/frontcraft/pages/pages-layout.component.ts index 8d00429..30c7e7b 100644 --- a/src/frontend/src/app/frontcraft/pages/pages-layout.component.ts +++ b/src/frontend/src/app/frontcraft/pages/pages-layout.component.ts @@ -27,9 +27,9 @@ export class PagesLayoutComponent implements AfterContentInit{ title: 'Loot Rules', link: '/frontcraft/rules', },{ - icon: "shield", - title: 'Armory', - link: '/frontcraft/armory' + icon: "shield", + title: 'Armory', + link: '/frontcraft/armory' }] constructor(