Why its Not Work for Particular Room in Socket

NodeJs code :

socket.on(‘joinRoom’,(room)=>{
console.log(room);
var id=socket.id;
var us ={room,id}
rooms.push(us);

io.to(room).emit('nm','NewPlayer Join In Group '+ room );

});

cocos2dx code :

void HelloWorld::dMsg(std::string msg){
_client->on(“nm”, CC_CALLBACK_2(HelloWorld::onReceiveEvent, this));
}

========= cant get msg from server in SocketIO in on Method =============

check something if I am wrong anywhere

and it Work on good in this :
io.sockets.emit(‘nm’, 'NewPlayer Join In Group '+ room);
but it will send every socket connect user i need to send for Particular user or room

Read this How to create socket in cocos2dx

Socket working proper im talking about different thing .

For particular room is not working

But that is sockeio question, why you are asking here? It has nothing to do with client side.
Try to look into socketio website or stackoverflow.

void HelloWorld::dMsg(std::string msg){
_client->on(“nm”, CC_CALLBACK_2(HelloWorld::onReceiveEvent, this));
}

there is not problem? right

please look into cpp-test for cocos2d-x side implementation.

1 Like

Yes, this should help you Thanks @smitpatel88

Sorry i miss 1 point from NodeJS now working good . its NodeJs side problem