Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- socket.on('joinRoom', function(userDetails){
- clientInfo[socket.id] = userDetails; //variable contains name and room joined.
- socket.join(userDetails.room);
- }
- function kickUser(socket){
- socket.leave(clientInfo[socket.id].room);
- delete clientInfo[socket.id];
- }
- function kickUser(socket){
- var info = clientInfo[socket.id];
- if (typeof info == 'undefined'){
- return;
- }
- Object.keys(clientInfo).forEach(function(socketId){
- if(info.room == clientInfo[socketId].room) {
- if (info.name != clientInfo[socketId].name){
- socket.leave(clientInfo[socketId].room);
- delete clientInfo[socketId];
- }
- }
- });
- }
- socket.on('connect', function {
- socket.send(JSON.stringify{do: "introduce", name: "User1", room: "dasRoom"})
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement