so i'm having a problem with Socket.io:
So in the server i'm sending a message to the client like that:
Note that the snippets below are just simplifications of what i'm doing
import { Server, Socket } from 'socket.io';
const app = express();
const http = require('http');
const server = http.createServer(app);
const io = new Server(server, { cors: { origin: '*' } });
io.on('connection', socket => {
socket.on('message', (data) => {
// ... some computation here
socket.emit('other message', computeddata); // Should only send to the
sender
});
});
And on the client im receiving it like that:
socket.on('connect', () => {
socket.emit('message');
});
socket.on('other message', (data) => {
console.log(data);
});
When the server emits the message to the socket, it should only send to the specific socket right? Well, ALL the connected sockets pick up on it.
How can I make it so that the message only sends to the sender?
I'm a bit new to socket.io, Thanks in advance!
i managed to fix the issue, there was a io.emit line that I somehow missed 3 times, that ruined the rest of the emits.
Oh god.....