-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
47 lines (38 loc) · 932 Bytes
/
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
var godot = require('godot');
exports.name = 'godot';
exports.attach = function () {
//
// Remark: initialize the godot client for sending all the things
//
var options = this.config.get('godot');
this.godot = godot.createClient(options);
};
//
// Remark: Make sure we connect so we can begin to send metrics over other
// plugins
//
exports.init = function (done) {
var returned = false;
this.godot.on('connect', function () {
if (returned) {
this.emit('godot:reconnect', 'info');
return;
}
returned = true;
this.emit('godot:connected', 'info')
done();
}.bind(this));
//
// Make sure this never happens unless we are initializing
//
this.godot.on('error', function (err) {
if (!returned) {
return done(err);
}
this.emit('godot:error', 'error', {
stack: err.stack,
message: err.message
})
}.bind(this));
this.godot.connect();
};