I can't figure out how to do the equivalent of socket.broadcast.emit but using the net module of node.js instead of socket.io. I'm trying to connect a flash front end using flash built in socket libraries and node.js. I'm finding it quite hard to find a good example.
I managed to connect using the net module, but I'm not sure how to emit to all clients connected. Any ideas?
Net does not have any support for something like this automatically, so it would be up to you to keep a list of all of the currently connected clients. You would add people to an array as they connect and remove them as they disconnect. Finally, you would need to add your own methods for sending data to each client, iterating over your list of currently connected clients and calling write
.
One difficulty that you will need to figure out on your own is how to separate each message. How will the client know where one message ends and the next begins? You will need some way to frame your messages so that the client can split them up. SocketIO's WebSocket implementation provides message framing automatically so users don't have to worry about it.