Closed SinanAkkoyun closed 2 years ago
Hi!
This is a good question. The goal of Websocket support in curveball will eventually probably be to just provide access to a single direct websocket to a client.
The ws
library has native support for broadcasting, but one of the thing this requires is keeping track of all open websockets, which is something Curveball will probably never do, just like it won't keep track of which HTTP requests are currently being served.
Instead, we just want to encourage people from moving that functionality to their own code. For example, you can create an EventEmitter on a server, and each new websocket connection can listen to a message
event and sometimes emit it.
Or, you want to create a Redis pubsub entry, and have many Node.js instance subscribe to it.
Long story short, despite that the ws
has this feature, @curveball/core
will probably never expose this; but we might create a separate plugin that does have this feature (but it would for sure have multi-server support).
I see, thank you very much! Yes, I implemented socket tracking etc on my own, I was just exactly wondering about what you described.
Hi! I wanted to broadcast on the wss and asked myself how I could access the wss Thanks :)