Answer the question
In order to leave comments, you need to log in
Random chat script how?
Hello, I have a question. I wrote a chat with rooms, according to the principle of pogovorisomnoi.ru, a random chat without registration) How to write all this correctly? I wrote a script for connecting the first two users in a queue, but the code has not been finalized, because when the client sends messages to the server, the server does not know to whom it is sent and sends it to the last room. Here is the actual code:
socket.on('getIns', function(){
if(queue.length == 0) queue.push(socket);
else {
room = "public-"+(room_id++);
queue[0].join(room);
socket.join(room);
io.sockets.to(room).emit('getIns', room);
queue = queue.slice(1, queue.length);
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question