Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

joinRoom Error, Unknown code every time #4

Open
skourtisk opened this issue Jun 7, 2021 · 1 comment
Open

joinRoom Error, Unknown code every time #4

skourtisk opened this issue Jun 7, 2021 · 1 comment

Comments

@skourtisk
Copy link

Everytime I try to Join Room I get unknown code error. console logging room.sockets returns undefined and numClients always logs 0. io.sockets.adapter.rooms[roomCode] also logs undefined

@elyska
Copy link

elyska commented Jul 11, 2021

I had the same issue. I changed the handleJoinGame function and it worked.

` function handleJoinGame(roomName){

    const room = io.sockets.adapter.rooms.get(roomName);
    
    let numClients = 0;
    if (room) {
        numClients = room.size;
    }

    if (numClients === 0) {
        client.emit('unknownCode');
        return;
    } else if (numClients > 1) {
        client.emit('tooManyPlayers');
        return;
    }


    clientRooms[client.id] = roomName;

    client.join(roomName);
    client.number = 2;
    client.emit('init', 2);

    startGameInterval(roomName);
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants