Link to home
Start Free TrialLog in
Avatar of roy wiliams
roy wiliams

asked on

Join room in another namespace in socket.io

I have this code bellow and it works great in socket.io version 1.3.7

this.gameInfra = io.of('/game_infra');
this.gameInfra.on('connection', (socket) => {

    socket.on('join_room', (room) => {
            var comSocket = self.chatCom.connected[socket.id];
            comSocket.join(room.name);
            comSocket.room = room.name;
     });
)};

this.chatCom = io.of('/chat_com');
this.chatCom.on('connection', (socket) => {
    socket.on('message', (message) => {
            message.username = self.gameInfra.connected[socket.id].username;
            socket.in(socket.room).broadcast.send(JSON.stringify(message));
    });
});

Open in new window


I want to upgrade my socket.io to the latest version but this code
var comSocket = self.chatCom.connected[socket.id]; 

Open in new window

is undefined in newer versions.

Anyone who nows the new syntax?
ASKER CERTIFIED SOLUTION
Avatar of Floyd jameson
Floyd jameson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Henrik pattson
Henrik pattson

Why do you want to upgrade your socket.io version?
Avatar of roy wiliams

ASKER

The last post in the link was my solution.

Thanks