I'm trying to use broadcast statement to send messages to specific user.
However, when I'm starting with self-sending messages using the following statement, it doesn't work. The client side cannot receive the message. So what's wrong with this statement?
io.on('connection', function(socket) {
socket.on('message', function(msg) {
socket.broadcast.to(socket.id).emit('message', msg);
});
});
(purpose of this code: the client side send a piece of message named 'message', the server receive the message and send back to the same client)