Created
June 28, 2019 11:19
-
-
Save barmgeat/26ded074db6ddf9664f52afad5aaee0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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