Use cws(uws) for Socket.IO engine

merge-requests/54/head
Moe 2019-02-24 18:47:39 -08:00
parent 490ac88b00
commit 9a71cd9c95
4 changed files with 12 additions and 3 deletions

View File

@ -8,7 +8,7 @@
// If you like what I am doing here and want me to continue please consider donating :)
// PayPal : paypal@m03.ca
//
var io = new (require('socket.io'))()
var io = new (require('socket.io'))
//library loader
var loadLib = function(lib){
return require(__dirname+'/libs/'+lib+'.js')
@ -22,7 +22,7 @@ var config = loadLib('config')(s)
//language loader
var lang = loadLib('language')(s,config)
//code test module
loadLib('codeTester')(s,config,lang,io)
loadLib('codeTester')(s,config,lang)
//basic functions
loadLib('basic')(s,config)
//video processing engine

View File

@ -1,6 +1,6 @@
var fs = require('fs');
var execSync = require('child_process').execSync;
module.exports = function(s,config,lang,io){
module.exports = function(s,config,lang){
var onFFmpegLoaded = function(ffmpeg){
if(process.argv[2] && process.argv[2].indexOf('test') > -1){
config.testMode = true

View File

@ -50,6 +50,8 @@ module.exports = function(s,config,lang,io){
if(config.renderPaths.grid === undefined){config.renderPaths.grid='pages/grid'}
//slick.js (cycle) page
if(config.renderPaths.cycle === undefined){config.renderPaths.cycle='pages/cycle'}
// Use uws/cws
if(config.useUWebsocketJs === undefined){config.useUWebsocketJs=true}
//SSL options
if(config.ssl&&config.ssl.key&&config.ssl.cert){
config.ssl.key=fs.readFileSync(s.checkRelativePath(config.ssl.key),'utf8')
@ -111,5 +113,11 @@ module.exports = function(s,config,lang,io){
path:s.checkCorrectPathEnding(config.webPaths.super)+'socket.io',
transports: ['websocket']
})
if(config.useUWebsocketJs === true){
io.engine.ws = new (require('cws').Server)({
noServer: true,
perMessageDeflate: false
})
}
return app
}

View File

@ -24,6 +24,7 @@
"body-parser": "^1.18.3",
"circular-json": "0.3.1",
"connection-tester": "^0.1.1",
"cws": "^1.0.0",
"discord.js": "^11.3.2",
"ejs": "^2.5.5",
"express": "^4.16.4",