SHARE
TWEET

Untitled

a guest Jun 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const httpServer = http.createServer(app);
  2. var io = require('socket.io')(httpServer);
  3. app.set('socketio', io);
  4.  
  5. io.sockets.on('connection', function (client) {
  6.   client.on('join', (data) => {
  7.     client.join(data.room);
  8.     console.log(client.id + " is connected.");  
  9.   });  
  10.   client.on('likeEvent', (data) => {  
  11.      client.broadcast.in(data.room).emit('like event', {message:'New '+data.module+' created.'});
  12.   });
  13.   client.on('commentEvent', (data) => {  
  14.      client.broadcast.in(data.room).emit('comment event', {message:'New '+data.module+' created.'});
  15.   });
  16.   client.on('commentPost', (data) => {  
  17.      client.broadcast.in(data.room).emit('comment post', {message:'New '+data.module+' created.'});
  18.   });
  19.   client.on('likePost', (data) => {
  20.      client.broadcast.in(data.room).emit('like post', {message:'New '+data.module+' created.'});
  21.   });
  22.   client.on('likeComment', (data) => {
  23.      client.broadcast.in(data.room).emit('like comment', {message:'New '+data.module+' created.'});
  24.   });
  25.   client.on('likePostComment', (data) => {    
  26.      client.broadcast.in(data.room).emit('like post comment', {message:'New '+data.module+' created.'});
  27.   });
  28. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top