Skip to content

Instantly share code, notes, and snippets.

@suissa
Created October 12, 2016 02:57
Show Gist options
  • Save suissa/c99eec4106150da070caf20500915e3b to your computer and use it in GitHub Desktop.
Save suissa/c99eec4106150da070caf20500915e3b to your computer and use it in GitHub Desktop.
const http = require('http')
const fs = require('fs')
const index = fs.readFileSync('./04.html');
const app = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(index);
}).listen(8080)
const io = require('socket.io').listen(app)
io.on('connection', (socket) => {
console.log('conexão com o Socket.io')
socket.on('disconnect', () => {
console.log('disconnect no socket')
})
socket.on('connect-client', (data) => {
const d1 = new Date(data)
console.log('connect do client em', d1.toGMTString())
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment