-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
53 lines (46 loc) · 1.61 KB
/
server.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
import createServer, {Events, Network} from 'monsterr'
import stage1 from './src/stages/stage1/server/server'
import stage0 from './src/stages/stage0/server/server'
import serverController from "./src/stages/stage1/server/server-controller";
const stages = [stage0, stage1];
let events = {
[Events.CLIENT_CONNECTED] (server, clientId) {
// Notify admin
console.log('CLIENT CONNECTED!§');
let msg = {clients: server.getPlayers()};
server.send('clientConnected', msg).toAdmin();
},
[Events.CLIENT_DISCONNECTED] (server, clientId) {
// Notify admin
console.log('CLIENT DISCONNECTED!§');
let msg = {clients: server.getPlayers()};
server.send('clientDisconnected', msg).toAdmin();
}
};
let commands = {
'getConnections': function (server, _, ...args) {
console.log('getConnections command received. Sending to admin...');
let msg = {clients: server.getPlayers()};
server.send('resConnections', msg).toAdmin();
},
'reqGameData': function (server, _, ...args) {
console.log('reqGameData command received on server..');
serverController.sendGameData();
},
'reqParticipantData': function (server, _, ...args) {
console.log('reqParticipantData command received on server..');
serverController.sendParticipantData();
},
}
const monsterr = createServer({
network: Network.pairs(16),
events,
commands,
stages,
options: {
port: 8080,
clientPassword: undefined, // can specify client password
adminPassword: 'sEcr3t' // and admin password
}
});
monsterr.run();