import {
	WebSocketGateway,
	SubscribeMessage,
	WebSocketServer,
	MessageBody,
} from '@nestjs/websockets';

@WebSocketGateway({
	cors: {
		origin: '*',
	},
})
export class ChatGateway {
	@WebSocketServer()
	server;

	@SubscribeMessage('message')
	handleMessage(@MessageBody() message: string): void {
		console.log("message received:");
		console.log(`[${message}]`);
		this.server.emit('message', message);
	}
}

