This repository was archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcli.js
More file actions
56 lines (47 loc) · 1.42 KB
/
cli.js
File metadata and controls
56 lines (47 loc) · 1.42 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
const logger = require('./logger')
var vorpal = require('vorpal')();
global.vorpal = vorpal;
vorpal
.delimiter('live~')
.show();
vorpal.command('kickClient <blid> [reason...]', 'Kicks client from glass live').action(function(args, callback) {
var cc = require('./clientConnection');
var client;
if((client = cc.getFromBlid(args.blid))) {
client.kick(args.reason.join(' '));
}
callback();
});
vorpal.command('listClients', 'Shows clients online').action(function(args, callback) {
var clients = require('./clientConnection').getAll();
var ct = 0;
for(var i in clients) {
ct++;
var cl = clients[i];
logger.log(cl.username + '\t' + cl.blid + '\t' + cl.socket.remoteAddress);
}
logger.log('Displayed ' + ct + ' users');
callback();
});
vorpal.command('shutdown <timeout> [reason...]', 'Issues a \'shutdown\' call to all clients. Client reconnect timeout in seconds').action(function(args, callback) {
var reason;
if(args.reason == null) {
reason = "";
} else {
reason = args.reason.join(' ');
reason.trim();
}
require('./chatServer').shutdown();
require('./clientConnection').sendObjectAll({
type: 'shutdown',
planned: true,
reason: reason,
timeout: args.timeout*1000
});
require('./dataLogging').logGlobalRoomEvent('sys', 'Planned shutdown initiated.');
logger.log('Quitting...');
setTimeout(function() {
process.exit(0);
}, 1000);
callback();
});