-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
70 lines (53 loc) · 1.64 KB
/
app.js
File metadata and controls
70 lines (53 loc) · 1.64 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const path = require("path").resolve(".")
const pathLink = path
const http = require('http')
const multer = require('multer')
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
const config = require('./static/js/config')
const httpPort = config.appPort
const logger = require(pathLink + '/server/public/methods/log4js').getLogger('App')
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(express.static(require('path').join(__dirname, 'public')))
app.use(bodyParser.json({limit: '50mb'}))
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}))
const objMulter = multer({dest: config.file.upload})
app.use(objMulter.any())
const httpServer = http.createServer(app).listen(httpPort)
const io = require('socket.io')({})
io.attach(httpServer)
/**
* router
*
*/
const uploadFile = require(pathLink + '/server/joinCM/uploadFile/index')
app.use('/uploadFile', uploadFile)
/**
* socket
*
*/
// app list enter
const StartSocket = require('./server/index')
let peopleCount = 0
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--
})
logger.info(peopleCount + ' user')
})