From 2ef8c15f630346d5d2723c8b8a2472a9146295fb Mon Sep 17 00:00:00 2001 From: "Kevin C. Coram" Date: Mon, 12 Oct 2020 12:09:02 -0400 Subject: [PATCH] Better typing of message handler --- apps/api/src/app/app.gateway.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/api/src/app/app.gateway.ts b/apps/api/src/app/app.gateway.ts index b20cf8b..cb2dd3d 100644 --- a/apps/api/src/app/app.gateway.ts +++ b/apps/api/src/app/app.gateway.ts @@ -10,8 +10,8 @@ import { WebSocketGateway, WebSocketServer, } from '@nestjs/websockets'; -import { Server } from 'http'; import { AppService } from './app.service'; +import { Server,Socket } from 'socket.io'; @WebSocketGateway(4001) export class AppGateway implements OnGatewayConnection { @@ -22,12 +22,12 @@ export class AppGateway implements OnGatewayConnection { constructor(private appService: AppService) {} - handleConnection(client: any, ...args: any[]) { + handleConnection(client: Socket, ...args: any[]) { client.emit(MESSAGE_TO_CLIENT, this.appService.getMessages()); } @SubscribeMessage(MESSAGE_TO_SERVER) - handleMessage(client: any, payload: Message): void { + handleMessage(client: Socket, payload: Message): void { this.logger.log(payload); this.appService.addMessage(payload); this.wss.emit(MESSAGE_TO_CLIENT, this.appService.getMessages());