Question about WebSocketGateway class - Emit to channel from external component
See original GitHub issueHi,
I have a simple WebSocketGateway:
import { WebSocketGateway, SubscribeMessage } from '@nestjs/websockets';
@WebSocketGateway({ port: 3001, namespace: 'ws' })
export class TestGateway {
@SubscribeMessage('channel-1')
onMessage(client, data) {
client.emit('channel-1', data);
}
}
I’m trying to send messages (broadcast) to this channel from other parts of the application (others components that can be or not inside the same module).
There is a way to do it without connecting via a socket.io client?
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
socket.io - How to access websocket from controller or another ...
Better solution is to create global module. You can then emit events from any other module/controller. A. Afir approach will create multiple ...
Read more >Gateways | NestJS - A progressive Node.js framework
This section covers the aspects of Nest that are specific to WebSockets. In Nest, a gateway is simply a class annotated with @WebSocketGateway()...
Read more >ESP32 WebSocket Server: Control Outputs (Arduino IDE)
Build a web server with the ESP32 using WebSocket communication protocol. We'll create a web page to control the ESP32 outputs remotely using...
Read more >Implementing a Java Server Side component for jWebSocket ...
The Java Class JwebSockClient that I have created will start the jWebSocket Server, then register itself as a listener on it.
Read more >Service Reference - Kaazing
The URL of a back-end service or message broker to which the proxy service (for example, proxy or amqp.proxy service) or broadcast service...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any idea to emit from controller?
Solved it using:
So I can: