How to access websocket from controller or another component/services?
问题 I have a REST API, I want to send event to the client via websocket. How to inject websocket instance in controller or another component? 回答1: Better solution is to create global module . You can then emit events from any other module/controller. A. Afir approach will create multiple instances of Gateway if you try to use it in other modules. Note : This is just simplest solution Create socket.module.ts import { Module, Global } from '@nestjs/common'; import { SocketService } from './socket