import { Socket } from 'socket.io' ; import { BaseWSController } from '../../../../shared/infra/http/models/BaseWSController' ; import { PayloadSchema , SetCanvasDataDTO , payloadSchema } from './SetCanvasDataDTO' ; import { SetCanvasDataUseCase } from './SetCanvasDataUseCase' ; import { logger } from "../../../../logger" ; export class SetCanvasDataController extends BaseWSController { private useCase : SetCanvasDataUseCase ; constructor ( useCase ) { super ( payloadSchema ) ; this . useCase = useCase ; } async executeImpl ( socket , req ) { const dto = { meetingId : req . meetingId , canvasId : req . canvasId , canvasJSON : req . event . canvasJSON , } ; try { socket . to ( dto . meetingId ) . emit ( 'canvas-update' , { meetingId : dto . meetingId , canvasId : dto . canvasId , event : { action : req . event . action , actionData : req . event . actionData , } , } ) ; const result = await this . useCase . execute ( dto ) ; } catch ( err ) { logger . error ( { error : err } , err ) ; } } }