-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
56 lines (40 loc) · 1.37 KB
/
app.js
File metadata and controls
56 lines (40 loc) · 1.37 KB
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
const path = require("path").resolve(".")
const pathLink = path
const http = require('http')
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const config = require('./src/static/config/index')
const httpPort = config.appPort
app.use(express.static(require('path').join(__dirname, 'public')))
app.all('*', function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Headers', 'X-Requested-With')
res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
res.header('X-Powered-By', '3.2.1')
res.header('Content-Type', 'application/json;charset=utf-8')
next()
})
app.use(bodyParser.json({limit: '50mb'}))
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}))
const httpServer = http.createServer(app).listen(httpPort)
const io = require('socket.io')({})
io.attach(httpServer)
let peopleCount = 0
const StartSocket = require('./server/index')
const readCsv = require(pathLink + '/server/table/index.js')
readCsv.readCsvGroup(io)
io.on('connection', function (socket) {
peopleCount ++
StartSocket(socket, io)
socket.on('joinDataList', (data) => {
socket.join(data)
})
socket.on('leaveDataList', (data) => {
socket.leave(data)
})
socket.on('disconnect',function(){
peopleCount--
})
console.log(peopleCount + ' user')
})