add https game server startup script

This commit is contained in:
WEBXOSS 2017-03-05 15:13:21 +08:00
parent 41cdea88f6
commit c05ae82fe2
2 changed files with 21 additions and 2 deletions

21
test.js
View file

@ -69,7 +69,26 @@ if (global.window) {
server.listen(port);
}
// game server
var gameServer = new require('http').createServer();
var getArg = function (key) {
var value = '';
process.argv.slice(2).forEach(function (arg) {
if (arg.indexOf(key + '=') === 0) {
value = arg.replace(key + '=', '');
}
});
return value;
};
var gameServer
if (getArg('key')) {
var fs = require('fs');
gameServer = require('https').createServer({
key: fs.readFileSync(getArg('key')),
cert: fs.readFileSync(getArg('cert')),
ca: fs.readFileSync(getArg('ca')),
});
} else {
gameServer = require('http').createServer();
}
io = require('socket.io')(gameServer,{
pingTimeout: 30000,
maxHttpBufferSize: 1024*1024,

@ -1 +1 @@
Subproject commit b69cfabd41cbea0059b03891f0a4c900fe2dbb09
Subproject commit 4b1c84b47a1bc3efac902b792fb46b4e95151b4a