20 lines
889 B
TypeScript
20 lines
889 B
TypeScript
import {CommandHandler, ICommandHandler} from '@nestjs/cqrs';
|
|
import {SendToastCommand} from '../../../game/commands/send-toast.command';
|
|
import {SharedService} from '../../../shared/shared.service';
|
|
import {Logger} from "@nestjs/common";
|
|
import {ISocketNotificationEvent} from "../../../Consts/types";
|
|
import {ClientNotificationType} from "../../socket.gateway";
|
|
|
|
@CommandHandler(SendToastCommand)
|
|
export class SendToastCommandHandler implements ICommandHandler<SendToastCommand> {
|
|
private readonly logger = new Logger(SendToastCommand.name);
|
|
constructor(private sharedService: SharedService) {
|
|
}
|
|
async execute(command: SendToastCommand) {
|
|
this.logger.verbose(`send notification: ${command.text}`);
|
|
this.sharedService.notifyAllClients<ISocketNotificationEvent>(ClientNotificationType.Notification, {
|
|
text: command.text,
|
|
timeout: command.timeout,
|
|
});
|
|
}
|
|
}
|