Skip to content

Instantly share code, notes, and snippets.

@barmgeat
Created June 28, 2019 11:19
Show Gist options
  • Save barmgeat/26ded074db6ddf9664f52afad5aaee0f to your computer and use it in GitHub Desktop.
Save barmgeat/26ded074db6ddf9664f52afad5aaee0f to your computer and use it in GitHub Desktop.
const app = require('express')();
const http = require('http').createServer(app);
const io = require('socket.io')(http);
const userFunctions = require('./userFunctions')
const hostname = '192.168.56.1';
const port = 3001;
io.on('connection', function (socket) {
console.log('a user connected');
socket.on('disconnect', function () {
console.log('user disconnected');
});
// handel Register
socket.on('register new user', data => {
userFunctions.registerNeuUser(data);
});
//handel login
socket.on('need login', data=>{
userFunctions.needLogin(data, socket);
});
});
http.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment