-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
86 lines (68 loc) · 1.98 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const express = require('express');
const app = express();
global.userCount = 0;
global.lastInfo = {
busy : false,
lastTitle : "pending",
lastPercentage : 0
};
global.botname = "";
global.endPipe = null;
global.myConfig = {
command: "",
filename: "",
ip : "",
port : 0,
filesize : 0
};
global.client = null;
global.checkIfStuck = null;
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.get('/', function(request, response) {
response.render('pages/index');
});
app.get('/vip/', function(request, response) {
response.render('vip/index');
});
app.get('/mongolian/', function(request, response) {
response.render('mongolian/index');
});
// app.get('/mongolian/error/', function(request, response) {
// response.send("Something went wrong.. please try again");
// });
var server = app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
global.io = require('socket.io')(server);
global.io.on('connection', (socket) => {
var sessionid = socket.id;
var xdcctestpipe = new require('./xdcctest-pipe.js')(sessionid);
global.userCount++;
userCountUpdate();
socket.on('disconnect', function () {
global.userCount--;
userCountUpdate();
});
socket.on('initiate', function (data) {
if (global.lastInfo.busy) {
socket.emit('wait', global.lastInfo);
}
else {
global.lastInfo.busy = true;
xdcctestpipe.connectIRC(data.botname, data.packnum);
}
});
app.get('/mongolian/download/', function(req, res){
xdcctestpipe.stream(req, res);
});
app.get('/mongolian/cancel/', function(req, res){
xdcctestpipe.cancel(req, res);
});
});
function userCountUpdate() {
global.io.sockets.emit('usercount', global.userCount);
}