wsApp.publish or ws.send? #818
-
Hi all! wsApp.publish('topic', message) or clients = new Map() // or object
clietns.forEach(u => {
u.send(message)
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Publish is much better. Not only will it iterate over 1000 clients faster, but the main feature of Publish is it automatically groups outgoing messages by socket before sending out, if you publish 100 different messages to some subset of 1000 clients it will be 100 times more efficient and faster than looping over and sending each message individually, because it can send all messages to a client at same time |
Beta Was this translation helpful? Give feedback.
-
wsApp.publish('topic', message) is made for this, so use it. But also make your own benchmarks. The follow up question I don't understand, you use loosely defined, or simply undefined, terminology. |
Beta Was this translation helpful? Give feedback.
wsApp.publish('topic', message) is made for this, so use it. But also make your own benchmarks. The follow up question I don't understand, you use loosely defined, or simply undefined, terminology.