Why its Not Work for Particular Room in Socket

Why its Not Work for Particular Room in Socket
0

#1

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


#2

Read this How to create socket in cocos2dx


#3

Socket working proper im talking about different thing .

For particular room is not working


#4

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.


#5

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

there is not problem? right


#6

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


#7

Yes, this should help you Thanks @smitpatel88


#8

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