-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamConnection.js
37 lines (29 loc) · 1.01 KB
/
streamConnection.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
var StreamManager = function () {
var that = this;
this.disconnect = function () {
this.socket.disconnect()
};
this.setup = function (config, forceNew, callback) {
var server = "http://atlas-stream.ripe.net";
var io_config = {path: "/stream/socket.io"};
if (this.socket){
that.socket.emit("atlas_unsubscribe", that.lastConfig);
that.socket.on("atlas_unsubscribed", function(){
console.log(config);
that.socket.emit("atlas_subscribe", config);
});
} else {
//Connect
this.socket = io(server, io_config);
//Send config
this.socket.on('connect', function () {
that.socket.emit("atlas_subscribe", config);
});
//Setup callback on messages
this.socket.on('atlas_probestatus', callback);
}
that.lastConfig = config;
//Logging
console.log("set config for", config);
}
};