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 { 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(ClientNotificationType.Notification, { text: command.text, timeout: command.timeout, }); } }