-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathws_example.js
64 lines (45 loc) · 1.45 KB
/
ws_example.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
//run "npm install socketcluster-client" in terminal before attempting to use
var socketCluster = require('socketcluster-client');
var api_credentials =
{
"apiKey" : "",
"apiSecret" : ""
}
var options = {
hostname : "sc-02.coinigy.com",
port : "443",
secure : "true"
};
console.log(options);
var SCsocket = socketCluster.connect(options);
SCsocket.on('connect', function (status) {
console.log(status);
SCsocket.on('error', function (err) {
console.log(err);
});
SCsocket.emit("auth", api_credentials, function (err, token) {
if (!err && token) {
var scChannel = SCsocket.subscribe("TRADE-OK--BTC--CNY");
console.log(scChannel);
scChannel.watch(function (data) {
console.log(data);
});
SCsocket.emit("exchanges", null, function (err, data) {
if (!err) {
console.log(data);
} else {
console.log(err)
}
});
SCsocket.emit("channels", "OK", function (err, data) {
if (!err) {
console.log(data);
} else {
console.log(err)
}
});
} else {
console.log(err)
}
});
});