repl.it
@octavelr/

easysnt-socketio

Nodejs

No description

fork
loading
Files
  • index.js
  • Packager files
  • package-lock.json
  • package.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

io.on('connection', function(socket){
  socket.on('disconnect', function(){
    console.log('user disconnected');
  });
  socket.on('socketLogin', user => {
    console.log(user+' is connected!');
    socket.on('login', data => {
      io.emit('checkSsid', data);
    })
    socket.on('sendUpdate', function(data) {
      console.log(user+": "+data);
      var msgData = JSON.stringify({user: user, content: data});
      io.emit('update', msgData);
    })
  })
});

http.listen(8080, function(){
  console.log('listening on *:8080');
});
Fetching token
?