I'm new in Node.js/Socket.io and in Back-End at all. While reading documentation I have started develop little project, but now I dont have enough knowledge to finish him. So I'm trying to create simple game via those technologies (front-end in react.js) and now I need to create unique invitation for two players. How I can do this? If something is not clear, please ask.
server.js
io.on('connection', (socket) => {
socket.on('passDataToServer', (a) => {
console.log(a);
});
socket.on('create', (room) => {
usersInRoom++;
if (usersInRoom > 2) {
console.log('room is full');
return;
};
socket.join(room);
console.log(usersInRoom);
});
});
client.js
function passDataToServer(data) {
socket.emit('passDataToServer', data);
}
function creatingRoom() {
socket.emit('create', 'room-1');
};
export { passDataToServer, creatingRoom }