From 98a0720c03ff82cd9011b1599beacde244e06b48 Mon Sep 17 00:00:00 2001 From: NFriedo <69233063+NFriedo@users.noreply.github.com> Date: Tue, 5 Mar 2024 15:12:26 +0100 Subject: [PATCH] add create-card feature --- src/socket/socket/socket.gateway.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/socket/socket/socket.gateway.ts b/src/socket/socket/socket.gateway.ts index 5e62432..ebb9de1 100644 --- a/src/socket/socket/socket.gateway.ts +++ b/src/socket/socket/socket.gateway.ts @@ -71,4 +71,17 @@ export class SocketGateway client.broadcast.emit('delete-card-success', data); client.emit('delete-card-success', data); } + + @SubscribeMessage('create-card-request') + handleCreateCard(client: any, data: any) { + this.logger.log(`Message received from client id: ${client.id}`); + this.logger.debug(`Payload: ${JSON.stringify(data)}`); + + const cardId = `card${Math.floor(Math.random() * 1000)}`; + const responsePayload = { ...data, cardId, text: '' }; + this.logger.debug(`Response Payload: ${JSON.stringify(responsePayload)}`); + + client.broadcast.emit('create-card-success', responsePayload); + client.emit('create-card-success', responsePayload); + } }