Solved

Join room in another namespace in socket.io

Posted on 2016-09-03
3
30 Views
Last Modified: 2016-09-04
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?
0
Comment
Question by:roy wiliams
3 Comments
 
LVL 1

Accepted Solution

by:
Floyd jameson earned 500 total points
ID: 41783394
0
 

Expert Comment

by:Henrik pattson
ID: 41783396
Why do you want to upgrade your socket.io version?
0
 

Author Closing Comment

by:roy wiliams
ID: 41783583
The last post in the link was my solution.

Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now