Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const app = require('express')();
- const http = require('http').Server(app);
- const io = require('socket.io')(http);
- app.get('/ping', function(req, res){
- res.send('pong');
- });
- io.on('connection', function(socket){
- console.log("Client connected...");
- socket.on('serverMessage', function(data) {
- console.log("Incomming message", data);
- // sending to all clients except sender
- socket.broadcast.emit('clientMessage', data);
- })
- });
- http.listen(1337, function(){
- console.log('listening on *:1337');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement