sip-lab 1.4.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/samples/g729.js +176 -165
- package/samples/late_negotiation.js +283 -271
- package/samples/register_subscribe.js +138 -0
- package/samples/simple.js +286 -273
- package/samples/sip_cancel.js +115 -103
- package/src/addon.cpp +1 -1
package/samples/sip_cancel.js
CHANGED
|
@@ -1,111 +1,123 @@
|
|
|
1
1
|
var sip = require ('../index.js')
|
|
2
|
-
var
|
|
2
|
+
var Zester = require('zester')
|
|
3
|
+
var z = new Zester()
|
|
3
4
|
var m = require('data-matching')
|
|
4
5
|
var sip_msg = require('sip-matching')
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
sip.
|
|
7
|
+
async function test() {
|
|
8
|
+
//sip.set_log_level(6)
|
|
9
|
+
sip.dtmf_aggregation_on(500)
|
|
8
10
|
|
|
9
|
-
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
11
|
+
z.trap_events(sip.event_source, 'event', (evt) => {
|
|
12
|
+
var e = evt.args[0]
|
|
13
|
+
return e
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
console.log(sip.start((data) => { console.log(data)} ))
|
|
17
|
+
|
|
18
|
+
t1 = sip.transport.create("127.0.0.1", 5090, 1)
|
|
19
|
+
t2 = sip.transport.create("127.0.0.1", 5092, 1)
|
|
20
|
+
|
|
21
|
+
console.log("t1", t1)
|
|
22
|
+
console.log("t2", t2)
|
|
23
|
+
|
|
24
|
+
flags = 0
|
|
25
|
+
|
|
26
|
+
oc = sip.call.create(t1.id, flags, 'sip:a@t', 'sip:b@127.0.0.1:5092')
|
|
27
|
+
|
|
28
|
+
await z.wait([
|
|
29
|
+
{
|
|
30
|
+
event: "incoming_call",
|
|
31
|
+
call_id: m.collect("call_id"),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
event: 'response',
|
|
35
|
+
call_id: oc.id,
|
|
36
|
+
method: 'INVITE',
|
|
37
|
+
msg: sip_msg({
|
|
38
|
+
$rs: '100',
|
|
39
|
+
$rr: 'Trying',
|
|
40
|
+
'$(hdrcnt(via))': 1,
|
|
41
|
+
'$hdr(call-id)': m.collect('sip_call_id'),
|
|
42
|
+
$fU: 'a',
|
|
43
|
+
$fd: 't',
|
|
44
|
+
$tU: 'b',
|
|
45
|
+
'$hdr(l)': '0',
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
], 1000)
|
|
49
|
+
|
|
50
|
+
ic = {
|
|
51
|
+
id: z.store.call_id,
|
|
52
|
+
sip_call_id: z.store.sip_call_id,
|
|
53
|
+
}
|
|
13
54
|
|
|
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
|
-
|
|
55
|
+
sip.call.respond(ic.id, 180, 'Ringing')
|
|
56
|
+
|
|
57
|
+
await z.wait([
|
|
58
|
+
{
|
|
59
|
+
event: 'response',
|
|
60
|
+
call_id: oc.id,
|
|
61
|
+
method: 'INVITE',
|
|
62
|
+
msg: sip_msg({
|
|
63
|
+
$rs: '180',
|
|
64
|
+
$rr: 'Ringing',
|
|
65
|
+
'$(hdrcnt(VIA))': 1,
|
|
66
|
+
$fU: 'a',
|
|
67
|
+
$fd: 't',
|
|
68
|
+
$tU: 'b',
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
], 1000)
|
|
72
|
+
|
|
73
|
+
sip.call.terminate(oc.id)
|
|
74
|
+
|
|
75
|
+
await z.wait([
|
|
76
|
+
{
|
|
77
|
+
event: 'request',
|
|
78
|
+
call_id: ic.id,
|
|
79
|
+
msg: sip_msg({
|
|
80
|
+
$rm: 'CANCEL',
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
event: 'response',
|
|
85
|
+
call_id: oc.id,
|
|
86
|
+
method: 'CANCEL',
|
|
87
|
+
msg: sip_msg({
|
|
88
|
+
$rs: '200',
|
|
89
|
+
$rr: 'OK',
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
event: 'response',
|
|
94
|
+
call_id: oc.id,
|
|
95
|
+
method: 'INVITE',
|
|
96
|
+
msg: sip_msg({
|
|
97
|
+
$rs: '487',
|
|
98
|
+
$rr: 'Request Terminated',
|
|
99
|
+
})
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
event: 'call_ended',
|
|
103
|
+
call_id: oc.id,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
event: 'call_ended',
|
|
107
|
+
call_id: ic.id,
|
|
108
|
+
},
|
|
109
|
+
], 1000)
|
|
110
|
+
|
|
111
|
+
await z.sleep(1000)
|
|
112
|
+
|
|
113
|
+
console.log("Success")
|
|
114
|
+
|
|
115
|
+
sip.stop()
|
|
51
116
|
}
|
|
52
117
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
method: 'INVITE',
|
|
60
|
-
msg: sip_msg({
|
|
61
|
-
$rs: '180',
|
|
62
|
-
$rr: 'Ringing',
|
|
63
|
-
'$(hdrcnt(VIA))': 1,
|
|
64
|
-
$fU: 'a',
|
|
65
|
-
$fd: 't',
|
|
66
|
-
$tU: 'b',
|
|
67
|
-
}),
|
|
68
|
-
},
|
|
69
|
-
], 1000)
|
|
70
|
-
|
|
71
|
-
sip.call.terminate(oc.id)
|
|
72
|
-
|
|
73
|
-
z.wait([
|
|
74
|
-
{
|
|
75
|
-
event: 'request',
|
|
76
|
-
call_id: ic.id,
|
|
77
|
-
msg: sip_msg({
|
|
78
|
-
$rm: 'CANCEL',
|
|
79
|
-
}),
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
event: 'response',
|
|
83
|
-
call_id: oc.id,
|
|
84
|
-
method: 'CANCEL',
|
|
85
|
-
msg: sip_msg({
|
|
86
|
-
$rs: '200',
|
|
87
|
-
$rr: 'OK',
|
|
88
|
-
}),
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
event: 'response',
|
|
92
|
-
call_id: oc.id,
|
|
93
|
-
method: 'INVITE',
|
|
94
|
-
msg: sip_msg({
|
|
95
|
-
$rs: '487',
|
|
96
|
-
$rr: 'Request Terminated',
|
|
97
|
-
})
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
event: 'call_ended',
|
|
101
|
-
call_id: oc.id,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
event: 'call_ended',
|
|
105
|
-
call_id: ic.id,
|
|
106
|
-
},
|
|
107
|
-
], 1000)
|
|
108
|
-
|
|
109
|
-
z.sleep(1000)
|
|
110
|
-
|
|
111
|
-
sip.stop()
|
|
118
|
+
test()
|
|
119
|
+
.catch(e => {
|
|
120
|
+
console.error(e)
|
|
121
|
+
process.exit(1)
|
|
122
|
+
})
|
|
123
|
+
|
package/src/addon.cpp
CHANGED
|
@@ -1209,7 +1209,7 @@ Napi::Value subscription_create(const Napi::CallbackInfo& info) {
|
|
|
1209
1209
|
Napi::Value subscription_subscribe(const Napi::CallbackInfo& info) {
|
|
1210
1210
|
Napi::Env env = info.Env();
|
|
1211
1211
|
|
|
1212
|
-
if (info.Length() <
|
|
1212
|
+
if (info.Length() < 2) {
|
|
1213
1213
|
Napi::Error::New(env, "Wrong number of arguments. Expected: subscription_id, expires [, additional_headers]").ThrowAsJavaScriptException();
|
|
1214
1214
|
return env.Null();
|
|
1215
1215
|
}
|