Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. var app = require('express')();
  2. var http = require('http').createServer(app);
  3. var io = require('socket.io')(http);
  4.  
  5. app.get('/', function(req, res){
  6. res.sendFile(__dirname + '/chat.html');
  7. });
  8.  
  9. io.on('connection', function(socket){
  10. socket.on('chat message', function(msg){
  11. io.emit('chat message', msg);
  12. });
  13. });
  14.  
  15. http.listen(3000, function(){
  16. console.log('listening on *:3000');
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement