Created
October 15, 2016 20:09
-
-
Save suissa/f249df285c1d06460e9d6e20f56181da 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 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) | |
const users = [] | |
io.on('connection', (socket) => { | |
console.log('conexão com o Socket.io') | |
socket.on('disconnect', () => { | |
console.log('disconnect no socket') | |
}) | |
socket.join('chat da uol') | |
socket.on('adduser', (user) => { | |
console.log('user', user) | |
users.push(user) | |
}) | |
socket.on('message', (msg) => { | |
console.log('message', msg) | |
}) | |
socket.on('connect-client', (data) => { | |
const d1 = new Date(data) | |
console.log('connect do client em', d1.toGMTString()) | |
}) | |
}) | |
// Entre em localhost:8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment