rooooms
This commit is contained in:
@@ -50,14 +50,18 @@ export default class SocketConsoleHandler {
|
||||
async #onMsg(ev: MessageEvent) {
|
||||
try {
|
||||
const parsed = JSON.parse(ev.data) as ConsoleItem;
|
||||
const zodd = ConsoleItemSchema.safeParse(parsed);
|
||||
if (!zodd.success) this.destroy();
|
||||
else if (zodd.data.e == ConsoleEvent.Command) {
|
||||
const data = await Server.Commands.dispatch(...zodd.data.d.split(' '));
|
||||
const zodParsed = ConsoleItemSchema.safeParse(parsed);
|
||||
|
||||
if (!zodParsed.success) this.destroy();
|
||||
|
||||
else if (zodParsed.data.e == ConsoleEvent.Command) {
|
||||
const data = await Server.Commands.dispatch(...zodParsed.data.d.split(' '));
|
||||
if (data instanceof Error) throw data;
|
||||
|
||||
this.send(ConsoleEvent.Message, chalk.gray(`> ${chalk.yellow(data)}`));
|
||||
}
|
||||
else if (zodd.data.e == ConsoleEvent.Close) this.destroy();
|
||||
else if (zodParsed.data.e == ConsoleEvent.Close) this.destroy();
|
||||
|
||||
} catch (err) {
|
||||
this.#log.e(err);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
CompletionMessage,
|
||||
Message,
|
||||
MessageKind,
|
||||
NotificationHandler,
|
||||
PushNotificationId,
|
||||
SignalMessageType,
|
||||
SignalRMessage,
|
||||
@@ -164,7 +165,7 @@ export class SignalRSocketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
sendNotification(id: PushNotificationId | string, args?: object) {
|
||||
sendNotification(id: PushNotificationId | NotificationHandler, args?: object) {
|
||||
const msg: SignalRMessage = {
|
||||
type: SignalMessageType.Invocation,
|
||||
target: "Notification",
|
||||
|
||||
@@ -182,4 +182,20 @@ export enum PushNotificationId {
|
||||
CommunityBoardUpdate = 95,
|
||||
CommunityBoardAnnouncementUpdate,
|
||||
InventionModerationStateChanged = 100,
|
||||
}
|
||||
}
|
||||
|
||||
const notificationHandlers = [
|
||||
"AccountUpdate",
|
||||
"SelfAccountUpdate",
|
||||
"AnnouncementUpdate",
|
||||
"AnnouncementDelete",
|
||||
"ChatMessageReceived",
|
||||
"CommerceSubscriptionUpdate",
|
||||
"RoomInstanceUpdate",
|
||||
"PresenceUpdate",
|
||||
"ModerationQuitGame",
|
||||
"AppVersionUpdate",
|
||||
"PlayerProgressionLevelUpdate",
|
||||
"ReputationUpdate"
|
||||
] as const;
|
||||
export type NotificationHandler = typeof notificationHandlers[number];
|
||||
Reference in New Issue
Block a user