daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // socket.io
  3. var socket = io.listen(app);
  4. var buffer = [];
  5.  
  6. socket.on('connection', function(client){
  7.     client.send({ buffer: buffer });
  8.     client.broadcast({ announcement: client.sessionId + ' connected' });
  9.    
  10.     client.on('message', function(message){
  11.         var msg = { message: [client.sessionId, message] };
  12.         buffer.push(msg);
  13.         if (buffer.length > 15) buffer.shift();
  14.         console.log(msg);
  15.         client.broadcast(msg);
  16.     });
  17.  
  18.     client.on('disconnect', function(){
  19.         client.broadcast({ announcement: client.sessionId + ' disconnected' });
  20.     });
  21. });
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