-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (24 loc) · 682 Bytes
/
index.js
File metadata and controls
32 lines (24 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var express = require("express");
var app = express();
var http = require("http").createServer(app);
var io = require("socket.io")(http);
//settings
io.on("connection", socket => {
//quando socket se disconectar da aplicacao
socket.on("disconnect", () => {
console.log("X desconectou: " + socket.id);
})
//capturando algum evento com o nome msg do front end
socket.on("msg", data => {
io.emit("showmsg", data);
console.log(data);
})
})
app.set("view engine", "ejs");
app.get("/", (req,res) => {
res.render("index");
})
const port = 8080
http.listen(port,'0.0.0.0', () => {
console.log(`app rodando na ${port}`)
})