-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
57 lines (37 loc) · 1.17 KB
/
server.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const express = require('express')
const app = express()
const http = require('http').createServer(app)
const PORT = process.env.PORT || 3000
http.listen(PORT, () => {
console.log(`Listening on port ${PORT}`)
})
app.use(express.static(__dirname + '/public'))
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html')
})
// Socket
const io = require('socket.io')(http)
io.on('connection', (socket) => {
console.log('Connected Bro...')
socket.on('message', (msg) => {
// console.log(msg);
socket.broadcast.emit('message', msg)
})
})
// const { Socket } = require("dgram")
// const express = require("express")
// const app = express()
// const http = require('http').createServer(app)
// const PORT = process.env.PORT || 3000
// http.listen(PORT, () => {
// console.log(`listing on port ${PORT}`)
// })
// app.use(express.static(__dirname + '/public'))
// app.get('/', (req, res) => {
// res.sendFile(__dirname + '/index.html')
// })
// //socket
// const io = require("socket.io")(http)
// io.on('connection', (socket) => {
// console.log("connected Bro ...")
// })