-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (59 loc) · 2.52 KB
/
index.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
58
59
60
61
62
63
64
65
66
'use strict';
const PREFS = require('./preferences.json');
var GoblinBase = require('goblin-base-server');
var goblinBase;
function configure(){
goblinBase = GoblinBase.getGoblinBase()
.hookLogs({ info: console.log, warn: console.log, error: console.error, fatal: console.error })
.hookCloudFunctionsLogs({ info: console.log, warn: console.log, error: console.error, fatal: console.error })
.configureDatabase({ connectionUrl: `mongodb://${PREFS.MONGODB_HOST}:${PREFS.MONGODB_PORT}/${PREFS.MONGODB_DATABASE_NAME}` })
.configureRedis(new GoblinBase.RedisConfig()
.setupSessionsClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 0 })
.setupLeaderboardClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 1 })
.setupMatchmakingClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 2 })
.setupPvpRoomClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 3 })
.setupSimpleGameplayClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 4 })
.setupServiceClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 5 })
.setupMaintenanceClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 6 })
.setupResourceLockerClient(PREFS.REDIS_HOST, PREFS.REDIS_PORT, { db: 7 })
)
.includeAccounts()
.includeProfiles()
.includeTickets()
.includeLeaderboards()
.includeMatchmaking()
.includePvp({
apiPrefix: 'api/v0/',
physicalHost: '127.0.0.1',
physicalPort: 7332,
displayPortWs: 7331,
displayPortWss: 0,
shareIPAddress: true,
bindUdpOnPort: 54321,
pairsCapacity: 50,
attachMessageTimeAtRoom: true
})
.includeSimplePve()
.includeCloudFunctions()
.addPlatform({
header: GoblinBase.PLATFORMS.STANDALONE,
minimumVersion: '0.0.0',
hmacSecretsMap: { '0.0.0': PREFS.HMAC_SECRET }
});
if(PREFS.TURN_ON_CORS){
goblinBase.enableNodeCors();
}
requireCloudFunctions();
}
function requireCloudFunctions(){
require('fs').readdirSync(require('path').join(__dirname, 'cloudFunctions')).forEach(filename => {
if(filename.endsWith('.js')){
goblinBase.requireAsCloudFunction(`./cloudFunctions/${filename}`);
}
});
run();
}
function run(){
goblinBase.start(PREFS.START_AT_PORT, PREFS.START_AT_HOST, 'api/v0/', () => process.send ? process.send('ready') : console.log(`"process.send('ready');"`));
}
configure();