Solved

Join room in another namespace in socket.io

Posted on 2016-09-03
3
71 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Non-Resizable Pharagraph 2 17
Duplicate Elements with JS / jQuery 3 24
Getting selected value using Jquery 3 20
Read text on Table 7 25
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

735 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