-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathexample.js
48 lines (40 loc) · 1.01 KB
/
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
'use strict';
var CallMonitor = require('./');
var fritzbox = {
address: '192.168.178.1',
port: '1012'
};
var monitor = new CallMonitor(fritzbox.address, fritzbox.port);
monitor.on('inbound', function (call) {
console.log('- Incoming');
console.log(call);
console.log('');
});
monitor.on('outbound', function (call) {
console.log('- Outgoing');
console.log(call);
console.log('');
});
monitor.on('connected', function (call) {
console.log('- Connection Established');
console.log(call);
console.log('');
});
monitor.on('disconnected', function (call) {
console.log('- Connection Ended');
console.log(call);
console.log('');
});
monitor.on('error', function (error) {
switch (error.code) {
case 'ENETUNREACH':
console.log(`Cannot reach ${error.address}:${error.port}. Please check your connection.`);
break;
case 'ECONNREFUSED':
console.log(`Connection refused on ${error.address}:${error.port}`);
break;
default:
console.log(error);
break;
}
});