node.js - Nodejs/socket.io/express chatroom, across different ports -


i had google , searched stack haven't found relating need. have user side of chat(port: 3000) have admin side of chat (port:3001). in user side enter name , other details form , join chat. after they appear in admin side of chat, admin can click on room, enter , start chatting... have following admin join room if on same port, unsure how them room when on different port(these specs have been given , cant change them):

admin client side:

$('body').on('click', '.chatroom', function(){       var chatroom = $(this).attr('data-room');       console.log('chatroom client side: '+chatroom);       socket.emit('switchroom', chatroom); }); 

admin server side:

socket.on('switchroom', function(newroom){     console.log('new room: '+newroom);     socket.join(newroom);     socket.emit('updatechat', 'server', 'you have connected '+ newroom);     socket.broadcast.to(socket.room).emit('updatechat', 'server', socket.username+' has left room');     socket.room = newroom;     socket.broadcast.to(newroom).emit('updatechat', 'server', username+' has joined room'); }); 

if need user side of code add in, not sure if first nodejs app, still figuring out.

thanks!


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -