sip-lab 1.12.39 → 1.13.0
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/DEV.md +19 -3
- package/README.md +3 -2
- package/binding.gyp +97 -86
- package/build_deps.sh +2 -1
- package/index.js +14 -7
- package/package.json +7 -2
- package/prebuilds/linux-x64/node.abi102.node +0 -0
- package/prebuilds/linux-x64/node.abi108.node +0 -0
- package/prebuilds/linux-x64/node.abi88.node +0 -0
- package/prebuilds/linux-x64/node.abi93.node +0 -0
- package/samples/16_audio_streams.js +179 -0
- package/samples/delayed_media.js +117 -81
- package/samples/g729.js +50 -28
- package/samples/mrcp_and_audio.js +445 -0
- package/samples/mrcp_and_audio.simplified_media.js +273 -0
- package/samples/mrcp_and_audio.switching_order.js +273 -0
- package/samples/options.js +82 -0
- package/samples/refer.js +247 -0
- package/samples/refuse_telephone_event.js +166 -0
- package/samples/register_no_expires.js +82 -0
- package/samples/register_subscribe.js +36 -4
- package/samples/reinvite_and_dtmf.js +236 -161
- package/samples/reinvite_audio_audio.js +320 -0
- package/samples/reinvite_with_hold_unhold.js +412 -0
- package/samples/send_and_receive_fax.js +4 -8
- package/samples/simple.js +5 -9
- package/samples/sip_cancel.js +4 -6
- package/samples/tcp_and_extra_headers.js +98 -45
- package/samples/two_audio_media.js +497 -0
- package/src/addon.cpp +488 -268
- package/src/event_templates.cpp +84 -35
- package/src/event_templates.hpp +22 -12
- package/src/idmanager.cpp +58 -57
- package/src/idmanager.hpp +10 -10
- package/src/log.cpp +9 -11
- package/src/log.hpp +4 -4
- package/src/sip.cpp +6838 -5041
- package/src/sip.hpp +26 -34
- package/src/packetdumper.cpp +0 -234
- package/src/packetdumper.hpp +0 -67
package/src/addon.cpp
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#define NAPI_EXPERIMENTAL /* for napi_threadsafe functions */
|
|
2
2
|
|
|
3
|
-
#include <napi.h>
|
|
4
3
|
#include "sip.hpp"
|
|
4
|
+
#include <napi.h>
|
|
5
5
|
#include <string>
|
|
6
6
|
|
|
7
7
|
//#include <boost/thread.hpp>
|
|
@@ -23,8 +23,8 @@ static pj_thread_t *poll_thread = NULL;
|
|
|
23
23
|
|
|
24
24
|
void poll()
|
|
25
25
|
{
|
|
26
|
-
pj_status_t status = pj_thread_register("main_thread", poll_thread_descriptor,
|
|
27
|
-
|
|
26
|
+
pj_status_t status = pj_thread_register("main_thread", poll_thread_descriptor,
|
|
27
|
+
&poll_thread); if(status != PJ_SUCCESS)
|
|
28
28
|
{
|
|
29
29
|
printf("pj_thread_register(poll_thread) failed\n");
|
|
30
30
|
exit(1);
|
|
@@ -35,26 +35,28 @@ void poll()
|
|
|
35
35
|
wait(50);
|
|
36
36
|
int res = __pjw_poll(buf);
|
|
37
37
|
if(res == 0) {
|
|
38
|
-
if(napi_call_threadsafe_function(tsf, buf, napi_tsfn_blocking) != napi_ok)
|
|
39
|
-
|
|
38
|
+
if(napi_call_threadsafe_function(tsf, buf, napi_tsfn_blocking) != napi_ok)
|
|
39
|
+
{ printf("napi_call_threadsafe_function falied\n");
|
|
40
40
|
}
|
|
41
41
|
//printf("js land called\n");
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
Napi::Value transport_create(const Napi::CallbackInfo& info) {
|
|
47
|
+
Napi::Value transport_create(const Napi::CallbackInfo &info) {
|
|
49
48
|
Napi::Env env = info.Env();
|
|
50
49
|
|
|
51
50
|
if (info.Length() != 1) {
|
|
52
|
-
Napi::TypeError::New(env, "Wrong number of arguments. Expected params")
|
|
51
|
+
Napi::TypeError::New(env, "Wrong number of arguments. Expected params")
|
|
52
|
+
.ThrowAsJavaScriptException();
|
|
53
53
|
return env.Null();
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (!info[0].IsString()) {
|
|
57
|
-
Napi::TypeError::New(env,
|
|
57
|
+
Napi::TypeError::New(env,
|
|
58
|
+
"Wrong argument type: params must be a JSON string.")
|
|
59
|
+
.ThrowAsJavaScriptException();
|
|
58
60
|
return env.Null();
|
|
59
61
|
}
|
|
60
62
|
|
|
@@ -63,38 +65,45 @@ Napi::Value transport_create(const Napi::CallbackInfo& info) {
|
|
|
63
65
|
int out_t_id;
|
|
64
66
|
char out_t_address[256];
|
|
65
67
|
int out_t_port;
|
|
66
|
-
int res =
|
|
68
|
+
int res =
|
|
69
|
+
pjw_transport_create(json.c_str(), &out_t_id, out_t_address, &out_t_port);
|
|
67
70
|
|
|
68
|
-
if(res != 0) {
|
|
71
|
+
if (res != 0) {
|
|
69
72
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
70
73
|
return env.Null();
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
Napi::Object obj = Napi::Object::New(env);
|
|
74
77
|
obj.Set(Napi::String::New(env, "id"), Napi::Number::New(env, out_t_id));
|
|
75
|
-
obj.Set(Napi::String::New(env, "address"),
|
|
78
|
+
obj.Set(Napi::String::New(env, "address"),
|
|
79
|
+
Napi::String::New(env, out_t_address));
|
|
76
80
|
obj.Set(Napi::String::New(env, "port"), Napi::Number::New(env, out_t_port));
|
|
77
81
|
|
|
78
82
|
return obj;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
Napi::Value account_create(const Napi::CallbackInfo& info) {
|
|
85
|
+
Napi::Value account_create(const Napi::CallbackInfo &info) {
|
|
83
86
|
Napi::Env env = info.Env();
|
|
84
87
|
|
|
85
88
|
if (info.Length() != 2) {
|
|
86
|
-
Napi::TypeError::New(
|
|
89
|
+
Napi::TypeError::New(
|
|
90
|
+
env, "Wrong number of arguments. Expected: transport_id, params.")
|
|
91
|
+
.ThrowAsJavaScriptException();
|
|
87
92
|
return env.Null();
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
if (!info[0].IsNumber()) {
|
|
91
|
-
Napi::TypeError::New(env,
|
|
96
|
+
Napi::TypeError::New(env,
|
|
97
|
+
"Wrong argument type: transport_id must be number.")
|
|
98
|
+
.ThrowAsJavaScriptException();
|
|
92
99
|
return env.Null();
|
|
93
100
|
}
|
|
94
101
|
int transport_id = info[0].As<Napi::Number>().Int32Value();
|
|
95
|
-
|
|
102
|
+
|
|
96
103
|
if (!info[1].IsString()) {
|
|
97
|
-
Napi::TypeError::New(env,
|
|
104
|
+
Napi::TypeError::New(env,
|
|
105
|
+
"Wrong argument type: params must be a JSON string.")
|
|
106
|
+
.ThrowAsJavaScriptException();
|
|
98
107
|
return env.Null();
|
|
99
108
|
}
|
|
100
109
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
@@ -102,7 +111,7 @@ Napi::Value account_create(const Napi::CallbackInfo& info) {
|
|
|
102
111
|
int out_a_id;
|
|
103
112
|
int res = pjw_account_create(transport_id, json.c_str(), &out_a_id);
|
|
104
113
|
|
|
105
|
-
if(res != 0) {
|
|
114
|
+
if (res != 0) {
|
|
106
115
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
107
116
|
return env.Null();
|
|
108
117
|
}
|
|
@@ -110,30 +119,33 @@ Napi::Value account_create(const Napi::CallbackInfo& info) {
|
|
|
110
119
|
return Napi::Number::New(env, out_a_id);
|
|
111
120
|
}
|
|
112
121
|
|
|
113
|
-
|
|
114
|
-
Napi::Value account_register(const Napi::CallbackInfo& info) {
|
|
122
|
+
Napi::Value account_register(const Napi::CallbackInfo &info) {
|
|
115
123
|
Napi::Env env = info.Env();
|
|
116
124
|
|
|
117
125
|
if (info.Length() != 2) {
|
|
118
|
-
Napi::TypeError::New(
|
|
126
|
+
Napi::TypeError::New(
|
|
127
|
+
env, "Wrong number of arguments. Expected: account_id, params.")
|
|
128
|
+
.ThrowAsJavaScriptException();
|
|
119
129
|
return env.Null();
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
if (!info[0].IsNumber()) {
|
|
123
|
-
Napi::TypeError::New(env, "Wrong argument type: account_id must be number.")
|
|
133
|
+
Napi::TypeError::New(env, "Wrong argument type: account_id must be number.")
|
|
134
|
+
.ThrowAsJavaScriptException();
|
|
124
135
|
return env.Null();
|
|
125
136
|
}
|
|
126
137
|
int account_id = info[0].As<Napi::Number>().Int32Value();
|
|
127
138
|
|
|
128
139
|
if (!info[1].IsString()) {
|
|
129
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
140
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
141
|
+
.ThrowAsJavaScriptException();
|
|
130
142
|
return env.Null();
|
|
131
143
|
}
|
|
132
144
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
133
145
|
|
|
134
146
|
int res = pjw_account_register(account_id, json.c_str());
|
|
135
147
|
|
|
136
|
-
if(res != 0) {
|
|
148
|
+
if (res != 0) {
|
|
137
149
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
138
150
|
return env.Null();
|
|
139
151
|
}
|
|
@@ -141,23 +153,25 @@ Napi::Value account_register(const Napi::CallbackInfo& info) {
|
|
|
141
153
|
return env.Null();
|
|
142
154
|
}
|
|
143
155
|
|
|
144
|
-
Napi::Value account_unregister(const Napi::CallbackInfo&
|
|
156
|
+
Napi::Value account_unregister(const Napi::CallbackInfo &info) {
|
|
145
157
|
Napi::Env env = info.Env();
|
|
146
158
|
|
|
147
159
|
if (info.Length() != 1) {
|
|
148
|
-
Napi::TypeError::New(env, "Wrong number of arguments. Expected: account_id")
|
|
160
|
+
Napi::TypeError::New(env, "Wrong number of arguments. Expected: account_id")
|
|
161
|
+
.ThrowAsJavaScriptException();
|
|
149
162
|
return env.Null();
|
|
150
163
|
}
|
|
151
164
|
|
|
152
165
|
if (!info[0].IsNumber()) {
|
|
153
|
-
Napi::TypeError::New(env, "Wrong argument type: account_id must be number.")
|
|
166
|
+
Napi::TypeError::New(env, "Wrong argument type: account_id must be number.")
|
|
167
|
+
.ThrowAsJavaScriptException();
|
|
154
168
|
return env.Null();
|
|
155
169
|
}
|
|
156
170
|
int account_id = info[0].As<Napi::Number>().Int32Value();
|
|
157
171
|
|
|
158
172
|
int res = pjw_account_unregister(account_id);
|
|
159
173
|
|
|
160
|
-
if(res != 0) {
|
|
174
|
+
if (res != 0) {
|
|
161
175
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
162
176
|
return env.Null();
|
|
163
177
|
}
|
|
@@ -165,23 +179,102 @@ Napi::Value account_unregister(const Napi::CallbackInfo& info) {
|
|
|
165
179
|
return env.Null();
|
|
166
180
|
}
|
|
167
181
|
|
|
182
|
+
Napi::Value request_create(const Napi::CallbackInfo &info) {
|
|
183
|
+
Napi::Env env = info.Env();
|
|
184
|
+
|
|
185
|
+
if (info.Length() != 2) {
|
|
186
|
+
Napi::Error::New(
|
|
187
|
+
env, "Wrong number of arguments. Expected: transport_id, params.")
|
|
188
|
+
.ThrowAsJavaScriptException();
|
|
189
|
+
return env.Null();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!info[0].IsNumber()) {
|
|
193
|
+
Napi::TypeError::New(env, "transport_id must be number.")
|
|
194
|
+
.ThrowAsJavaScriptException();
|
|
195
|
+
return env.Null();
|
|
196
|
+
}
|
|
197
|
+
int transport_id = info[0].As<Napi::Number>().Int32Value();
|
|
198
|
+
|
|
199
|
+
if (!info[1].IsString()) {
|
|
200
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
201
|
+
.ThrowAsJavaScriptException();
|
|
202
|
+
return env.Null();
|
|
203
|
+
}
|
|
204
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
205
|
+
|
|
206
|
+
long int out_request_id;
|
|
207
|
+
char out_sip_call_id[256];
|
|
208
|
+
|
|
209
|
+
int res = pjw_request_create(transport_id, json.c_str(), &out_request_id,
|
|
210
|
+
out_sip_call_id);
|
|
211
|
+
|
|
212
|
+
if (res != 0) {
|
|
213
|
+
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
214
|
+
return env.Null();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
218
|
+
obj.Set(Napi::String::New(env, "id"), Napi::Number::New(env, out_request_id));
|
|
219
|
+
obj.Set(Napi::String::New(env, "sip_call_id"), out_sip_call_id);
|
|
220
|
+
|
|
221
|
+
return obj;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
Napi::Value request_respond(const Napi::CallbackInfo &info) {
|
|
225
|
+
Napi::Env env = info.Env();
|
|
226
|
+
|
|
227
|
+
if (info.Length() != 2) {
|
|
228
|
+
Napi::Error::New(env,
|
|
229
|
+
"Wrong number of arguments. Expected: request_id, params")
|
|
230
|
+
.ThrowAsJavaScriptException();
|
|
231
|
+
return env.Null();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!info[0].IsNumber()) {
|
|
235
|
+
Napi::TypeError::New(env, "request_id must be number.")
|
|
236
|
+
.ThrowAsJavaScriptException();
|
|
237
|
+
return env.Null();
|
|
238
|
+
}
|
|
239
|
+
int request_id = info[0].As<Napi::Number>().Int32Value();
|
|
240
|
+
|
|
241
|
+
if (!info[1].IsString()) {
|
|
242
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
243
|
+
.ThrowAsJavaScriptException();
|
|
244
|
+
return env.Null();
|
|
245
|
+
}
|
|
246
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
168
247
|
|
|
169
|
-
|
|
248
|
+
int res = pjw_request_respond(request_id, json.c_str());
|
|
249
|
+
|
|
250
|
+
if (res != 0) {
|
|
251
|
+
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
252
|
+
return env.Null();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return env.Null();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
Napi::Value call_create(const Napi::CallbackInfo &info) {
|
|
170
259
|
Napi::Env env = info.Env();
|
|
171
260
|
|
|
172
261
|
if (info.Length() != 2) {
|
|
173
|
-
Napi::Error::New(
|
|
262
|
+
Napi::Error::New(
|
|
263
|
+
env, "Wrong number of arguments. Expected: transport_id, params.")
|
|
264
|
+
.ThrowAsJavaScriptException();
|
|
174
265
|
return env.Null();
|
|
175
266
|
}
|
|
176
267
|
|
|
177
268
|
if (!info[0].IsNumber()) {
|
|
178
|
-
Napi::TypeError::New(env, "transport_id must be number.")
|
|
269
|
+
Napi::TypeError::New(env, "transport_id must be number.")
|
|
270
|
+
.ThrowAsJavaScriptException();
|
|
179
271
|
return env.Null();
|
|
180
272
|
}
|
|
181
273
|
int transport_id = info[0].As<Napi::Number>().Int32Value();
|
|
182
274
|
|
|
183
275
|
if (!info[1].IsString()) {
|
|
184
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
276
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
277
|
+
.ThrowAsJavaScriptException();
|
|
185
278
|
return env.Null();
|
|
186
279
|
}
|
|
187
280
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
@@ -189,9 +282,10 @@ Napi::Value call_create(const Napi::CallbackInfo& info) {
|
|
|
189
282
|
long int out_call_id;
|
|
190
283
|
char out_sip_call_id[256];
|
|
191
284
|
|
|
192
|
-
int res = pjw_call_create(transport_id, json.c_str(), &out_call_id,
|
|
285
|
+
int res = pjw_call_create(transport_id, json.c_str(), &out_call_id,
|
|
286
|
+
out_sip_call_id);
|
|
193
287
|
|
|
194
|
-
if(res != 0) {
|
|
288
|
+
if (res != 0) {
|
|
195
289
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
196
290
|
return env.Null();
|
|
197
291
|
}
|
|
@@ -203,29 +297,33 @@ Napi::Value call_create(const Napi::CallbackInfo& info) {
|
|
|
203
297
|
return obj;
|
|
204
298
|
}
|
|
205
299
|
|
|
206
|
-
Napi::Value call_respond(const Napi::CallbackInfo&
|
|
300
|
+
Napi::Value call_respond(const Napi::CallbackInfo &info) {
|
|
207
301
|
Napi::Env env = info.Env();
|
|
208
302
|
|
|
209
303
|
if (info.Length() != 2) {
|
|
210
|
-
Napi::Error::New(env,
|
|
304
|
+
Napi::Error::New(env,
|
|
305
|
+
"Wrong number of arguments. Expected: call_id, params")
|
|
306
|
+
.ThrowAsJavaScriptException();
|
|
211
307
|
return env.Null();
|
|
212
308
|
}
|
|
213
309
|
|
|
214
310
|
if (!info[0].IsNumber()) {
|
|
215
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
311
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
312
|
+
.ThrowAsJavaScriptException();
|
|
216
313
|
return env.Null();
|
|
217
314
|
}
|
|
218
315
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
219
|
-
|
|
316
|
+
|
|
220
317
|
if (!info[1].IsString()) {
|
|
221
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
318
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
319
|
+
.ThrowAsJavaScriptException();
|
|
222
320
|
return env.Null();
|
|
223
321
|
}
|
|
224
322
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
225
323
|
|
|
226
324
|
int res = pjw_call_respond(call_id, json.c_str());
|
|
227
325
|
|
|
228
|
-
if(res != 0) {
|
|
326
|
+
if (res != 0) {
|
|
229
327
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
230
328
|
return env.Null();
|
|
231
329
|
}
|
|
@@ -233,29 +331,33 @@ Napi::Value call_respond(const Napi::CallbackInfo& info) {
|
|
|
233
331
|
return env.Null();
|
|
234
332
|
}
|
|
235
333
|
|
|
236
|
-
Napi::Value call_terminate(const Napi::CallbackInfo&
|
|
334
|
+
Napi::Value call_terminate(const Napi::CallbackInfo &info) {
|
|
237
335
|
Napi::Env env = info.Env();
|
|
238
336
|
|
|
239
337
|
if (info.Length() != 2) {
|
|
240
|
-
Napi::Error::New(env,
|
|
338
|
+
Napi::Error::New(env,
|
|
339
|
+
"Wrong number of arguments. Expected: call_id, params")
|
|
340
|
+
.ThrowAsJavaScriptException();
|
|
241
341
|
return env.Null();
|
|
242
342
|
}
|
|
243
343
|
|
|
244
344
|
if (!info[0].IsNumber()) {
|
|
245
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
345
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
346
|
+
.ThrowAsJavaScriptException();
|
|
246
347
|
return env.Null();
|
|
247
348
|
}
|
|
248
349
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
249
|
-
|
|
350
|
+
|
|
250
351
|
if (!info[1].IsString()) {
|
|
251
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
352
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
353
|
+
.ThrowAsJavaScriptException();
|
|
252
354
|
return env.Null();
|
|
253
355
|
}
|
|
254
356
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
255
357
|
|
|
256
358
|
int res = pjw_call_terminate(call_id, json.c_str());
|
|
257
359
|
|
|
258
|
-
if(res != 0) {
|
|
360
|
+
if (res != 0) {
|
|
259
361
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
260
362
|
return env.Null();
|
|
261
363
|
}
|
|
@@ -263,29 +365,33 @@ Napi::Value call_terminate(const Napi::CallbackInfo& info) {
|
|
|
263
365
|
return env.Null();
|
|
264
366
|
}
|
|
265
367
|
|
|
266
|
-
Napi::Value call_send_dtmf(const Napi::CallbackInfo&
|
|
368
|
+
Napi::Value call_send_dtmf(const Napi::CallbackInfo &info) {
|
|
267
369
|
Napi::Env env = info.Env();
|
|
268
370
|
|
|
269
371
|
if (info.Length() != 2) {
|
|
270
|
-
Napi::Error::New(env,
|
|
372
|
+
Napi::Error::New(env,
|
|
373
|
+
"Wrong number of arguments. Expected: call_id, params.")
|
|
374
|
+
.ThrowAsJavaScriptException();
|
|
271
375
|
return env.Null();
|
|
272
376
|
}
|
|
273
377
|
|
|
274
378
|
if (!info[0].IsNumber()) {
|
|
275
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
379
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
380
|
+
.ThrowAsJavaScriptException();
|
|
276
381
|
return env.Null();
|
|
277
382
|
}
|
|
278
383
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
279
|
-
|
|
384
|
+
|
|
280
385
|
if (!info[1].IsString()) {
|
|
281
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
386
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
387
|
+
.ThrowAsJavaScriptException();
|
|
282
388
|
return env.Null();
|
|
283
389
|
}
|
|
284
390
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
285
391
|
|
|
286
392
|
int res = pjw_call_send_dtmf(call_id, json.c_str());
|
|
287
393
|
|
|
288
|
-
if(res != 0) {
|
|
394
|
+
if (res != 0) {
|
|
289
395
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
290
396
|
return env.Null();
|
|
291
397
|
}
|
|
@@ -293,29 +399,33 @@ Napi::Value call_send_dtmf(const Napi::CallbackInfo& info) {
|
|
|
293
399
|
return env.Null();
|
|
294
400
|
}
|
|
295
401
|
|
|
296
|
-
Napi::Value call_reinvite(const Napi::CallbackInfo&
|
|
402
|
+
Napi::Value call_reinvite(const Napi::CallbackInfo &info) {
|
|
297
403
|
Napi::Env env = info.Env();
|
|
298
404
|
|
|
299
405
|
if (info.Length() != 2) {
|
|
300
|
-
Napi::Error::New(env,
|
|
406
|
+
Napi::Error::New(env,
|
|
407
|
+
"Wrong number of arguments. Expected: call_id, params.")
|
|
408
|
+
.ThrowAsJavaScriptException();
|
|
301
409
|
return env.Null();
|
|
302
410
|
}
|
|
303
411
|
|
|
304
412
|
if (!info[0].IsNumber()) {
|
|
305
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
413
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
414
|
+
.ThrowAsJavaScriptException();
|
|
306
415
|
return env.Null();
|
|
307
416
|
}
|
|
308
417
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
309
|
-
|
|
418
|
+
|
|
310
419
|
if (!info[1].IsString()) {
|
|
311
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
420
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
421
|
+
.ThrowAsJavaScriptException();
|
|
312
422
|
return env.Null();
|
|
313
423
|
}
|
|
314
424
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
315
425
|
|
|
316
426
|
int res = pjw_call_reinvite(call_id, json.c_str());
|
|
317
427
|
|
|
318
|
-
if(res != 0) {
|
|
428
|
+
if (res != 0) {
|
|
319
429
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
320
430
|
return env.Null();
|
|
321
431
|
}
|
|
@@ -323,29 +433,33 @@ Napi::Value call_reinvite(const Napi::CallbackInfo& info) {
|
|
|
323
433
|
return env.Null();
|
|
324
434
|
}
|
|
325
435
|
|
|
326
|
-
Napi::Value call_send_request(const Napi::CallbackInfo&
|
|
436
|
+
Napi::Value call_send_request(const Napi::CallbackInfo &info) {
|
|
327
437
|
Napi::Env env = info.Env();
|
|
328
438
|
|
|
329
439
|
if (info.Length() != 2) {
|
|
330
|
-
Napi::Error::New(env,
|
|
440
|
+
Napi::Error::New(env,
|
|
441
|
+
"Wrong number of arguments. Expected: call_id, params.")
|
|
442
|
+
.ThrowAsJavaScriptException();
|
|
331
443
|
return env.Null();
|
|
332
444
|
}
|
|
333
445
|
|
|
334
446
|
if (!info[0].IsNumber()) {
|
|
335
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
447
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
448
|
+
.ThrowAsJavaScriptException();
|
|
336
449
|
return env.Null();
|
|
337
450
|
}
|
|
338
451
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
339
|
-
|
|
452
|
+
|
|
340
453
|
if (!info[1].IsString()) {
|
|
341
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
454
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
455
|
+
.ThrowAsJavaScriptException();
|
|
342
456
|
return env.Null();
|
|
343
457
|
}
|
|
344
458
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
345
459
|
|
|
346
460
|
int res = pjw_call_send_request(call_id, json.c_str());
|
|
347
461
|
|
|
348
|
-
if(res != 0) {
|
|
462
|
+
if (res != 0) {
|
|
349
463
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
350
464
|
return env.Null();
|
|
351
465
|
}
|
|
@@ -353,29 +467,33 @@ Napi::Value call_send_request(const Napi::CallbackInfo& info) {
|
|
|
353
467
|
return env.Null();
|
|
354
468
|
}
|
|
355
469
|
|
|
356
|
-
Napi::Value call_start_record_wav(const Napi::CallbackInfo&
|
|
470
|
+
Napi::Value call_start_record_wav(const Napi::CallbackInfo &info) {
|
|
357
471
|
Napi::Env env = info.Env();
|
|
358
472
|
|
|
359
473
|
if (info.Length() != 2) {
|
|
360
|
-
Napi::Error::New(env,
|
|
474
|
+
Napi::Error::New(env,
|
|
475
|
+
"Wrong number of arguments. Expected: call_id, params.")
|
|
476
|
+
.ThrowAsJavaScriptException();
|
|
361
477
|
return env.Null();
|
|
362
478
|
}
|
|
363
479
|
|
|
364
480
|
if (!info[0].IsNumber()) {
|
|
365
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
481
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
482
|
+
.ThrowAsJavaScriptException();
|
|
366
483
|
return env.Null();
|
|
367
484
|
}
|
|
368
485
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
369
|
-
|
|
486
|
+
|
|
370
487
|
if (!info[1].IsString()) {
|
|
371
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
488
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
489
|
+
.ThrowAsJavaScriptException();
|
|
372
490
|
return env.Null();
|
|
373
491
|
}
|
|
374
492
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
375
493
|
|
|
376
494
|
int res = pjw_call_start_record_wav(call_id, json.c_str());
|
|
377
495
|
|
|
378
|
-
if(res != 0) {
|
|
496
|
+
if (res != 0) {
|
|
379
497
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
380
498
|
return env.Null();
|
|
381
499
|
}
|
|
@@ -383,29 +501,33 @@ Napi::Value call_start_record_wav(const Napi::CallbackInfo& info) {
|
|
|
383
501
|
return env.Null();
|
|
384
502
|
}
|
|
385
503
|
|
|
386
|
-
Napi::Value call_start_play_wav(const Napi::CallbackInfo&
|
|
504
|
+
Napi::Value call_start_play_wav(const Napi::CallbackInfo &info) {
|
|
387
505
|
Napi::Env env = info.Env();
|
|
388
506
|
|
|
389
507
|
if (info.Length() != 2) {
|
|
390
|
-
Napi::Error::New(env,
|
|
508
|
+
Napi::Error::New(env,
|
|
509
|
+
"Wrong number of arguments. Expected: call_id, params.")
|
|
510
|
+
.ThrowAsJavaScriptException();
|
|
391
511
|
return env.Null();
|
|
392
512
|
}
|
|
393
513
|
|
|
394
514
|
if (!info[0].IsNumber()) {
|
|
395
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
515
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
516
|
+
.ThrowAsJavaScriptException();
|
|
396
517
|
return env.Null();
|
|
397
518
|
}
|
|
398
519
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
399
|
-
|
|
520
|
+
|
|
400
521
|
if (!info[1].IsString()) {
|
|
401
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
522
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
523
|
+
.ThrowAsJavaScriptException();
|
|
402
524
|
return env.Null();
|
|
403
525
|
}
|
|
404
526
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
405
527
|
|
|
406
528
|
int res = pjw_call_start_play_wav(call_id, json.c_str());
|
|
407
529
|
|
|
408
|
-
if(res != 0) {
|
|
530
|
+
if (res != 0) {
|
|
409
531
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
410
532
|
return env.Null();
|
|
411
533
|
}
|
|
@@ -413,29 +535,33 @@ Napi::Value call_start_play_wav(const Napi::CallbackInfo& info) {
|
|
|
413
535
|
return env.Null();
|
|
414
536
|
}
|
|
415
537
|
|
|
416
|
-
Napi::Value call_start_fax(const Napi::CallbackInfo&
|
|
538
|
+
Napi::Value call_start_fax(const Napi::CallbackInfo &info) {
|
|
417
539
|
Napi::Env env = info.Env();
|
|
418
540
|
|
|
419
541
|
if (info.Length() != 2) {
|
|
420
|
-
Napi::Error::New(env,
|
|
542
|
+
Napi::Error::New(env,
|
|
543
|
+
"Wrong number of arguments. Expected: call_id, params.")
|
|
544
|
+
.ThrowAsJavaScriptException();
|
|
421
545
|
return env.Null();
|
|
422
546
|
}
|
|
423
547
|
|
|
424
548
|
if (!info[0].IsNumber()) {
|
|
425
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
549
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
550
|
+
.ThrowAsJavaScriptException();
|
|
426
551
|
return env.Null();
|
|
427
552
|
}
|
|
428
553
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
429
|
-
|
|
554
|
+
|
|
430
555
|
if (!info[1].IsString()) {
|
|
431
|
-
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
556
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
557
|
+
.ThrowAsJavaScriptException();
|
|
432
558
|
return env.Null();
|
|
433
559
|
}
|
|
434
560
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
435
561
|
|
|
436
562
|
int res = pjw_call_start_fax(call_id, json.c_str());
|
|
437
563
|
|
|
438
|
-
if(res != 0) {
|
|
564
|
+
if (res != 0) {
|
|
439
565
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
440
566
|
return env.Null();
|
|
441
567
|
}
|
|
@@ -443,23 +569,33 @@ Napi::Value call_start_fax(const Napi::CallbackInfo& info) {
|
|
|
443
569
|
return env.Null();
|
|
444
570
|
}
|
|
445
571
|
|
|
446
|
-
Napi::Value call_stop_record_wav(const Napi::CallbackInfo&
|
|
572
|
+
Napi::Value call_stop_record_wav(const Napi::CallbackInfo &info) {
|
|
447
573
|
Napi::Env env = info.Env();
|
|
448
574
|
|
|
449
|
-
if (info.Length() !=
|
|
450
|
-
Napi::Error::New(env,
|
|
575
|
+
if (info.Length() != 2) {
|
|
576
|
+
Napi::Error::New(env,
|
|
577
|
+
"Wrong number of arguments. Expected: call_id, params")
|
|
578
|
+
.ThrowAsJavaScriptException();
|
|
451
579
|
return env.Null();
|
|
452
580
|
}
|
|
453
581
|
|
|
454
582
|
if (!info[0].IsNumber()) {
|
|
455
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
583
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
584
|
+
.ThrowAsJavaScriptException();
|
|
456
585
|
return env.Null();
|
|
457
586
|
}
|
|
458
587
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
459
588
|
|
|
460
|
-
|
|
589
|
+
if (!info[1].IsString()) {
|
|
590
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
591
|
+
.ThrowAsJavaScriptException();
|
|
592
|
+
return env.Null();
|
|
593
|
+
}
|
|
594
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
461
595
|
|
|
462
|
-
|
|
596
|
+
int res = pjw_call_stop_record_wav(call_id, json.c_str());
|
|
597
|
+
|
|
598
|
+
if (res != 0) {
|
|
463
599
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
464
600
|
return env.Null();
|
|
465
601
|
}
|
|
@@ -467,23 +603,33 @@ Napi::Value call_stop_record_wav(const Napi::CallbackInfo& info) {
|
|
|
467
603
|
return env.Null();
|
|
468
604
|
}
|
|
469
605
|
|
|
470
|
-
Napi::Value call_stop_play_wav(const Napi::CallbackInfo&
|
|
606
|
+
Napi::Value call_stop_play_wav(const Napi::CallbackInfo &info) {
|
|
471
607
|
Napi::Env env = info.Env();
|
|
472
608
|
|
|
473
|
-
if (info.Length() !=
|
|
474
|
-
Napi::Error::New(env,
|
|
609
|
+
if (info.Length() != 2) {
|
|
610
|
+
Napi::Error::New(env,
|
|
611
|
+
"Wrong number of arguments. Expected: call_id, params")
|
|
612
|
+
.ThrowAsJavaScriptException();
|
|
475
613
|
return env.Null();
|
|
476
614
|
}
|
|
477
615
|
|
|
478
616
|
if (!info[0].IsNumber()) {
|
|
479
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
617
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
618
|
+
.ThrowAsJavaScriptException();
|
|
480
619
|
return env.Null();
|
|
481
620
|
}
|
|
482
621
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
483
622
|
|
|
484
|
-
|
|
623
|
+
if (!info[1].IsString()) {
|
|
624
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
625
|
+
.ThrowAsJavaScriptException();
|
|
626
|
+
return env.Null();
|
|
627
|
+
}
|
|
628
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
485
629
|
|
|
486
|
-
|
|
630
|
+
int res = pjw_call_stop_play_wav(call_id, json.c_str());
|
|
631
|
+
|
|
632
|
+
if (res != 0) {
|
|
487
633
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
488
634
|
return env.Null();
|
|
489
635
|
}
|
|
@@ -491,23 +637,32 @@ Napi::Value call_stop_play_wav(const Napi::CallbackInfo& info) {
|
|
|
491
637
|
return env.Null();
|
|
492
638
|
}
|
|
493
639
|
|
|
494
|
-
Napi::Value call_stop_fax(const Napi::CallbackInfo&
|
|
640
|
+
Napi::Value call_stop_fax(const Napi::CallbackInfo &info) {
|
|
495
641
|
Napi::Env env = info.Env();
|
|
496
642
|
|
|
497
|
-
if (info.Length() !=
|
|
498
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id")
|
|
643
|
+
if (info.Length() != 2) {
|
|
644
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id")
|
|
645
|
+
.ThrowAsJavaScriptException();
|
|
499
646
|
return env.Null();
|
|
500
647
|
}
|
|
501
648
|
|
|
502
649
|
if (!info[0].IsNumber()) {
|
|
503
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
650
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
651
|
+
.ThrowAsJavaScriptException();
|
|
504
652
|
return env.Null();
|
|
505
653
|
}
|
|
506
654
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
507
655
|
|
|
508
|
-
|
|
656
|
+
if (!info[1].IsString()) {
|
|
657
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
658
|
+
.ThrowAsJavaScriptException();
|
|
659
|
+
return env.Null();
|
|
660
|
+
}
|
|
661
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
662
|
+
|
|
663
|
+
int res = pjw_call_stop_fax(call_id, json.c_str());
|
|
509
664
|
|
|
510
|
-
if(res != 0) {
|
|
665
|
+
if (res != 0) {
|
|
511
666
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
512
667
|
return env.Null();
|
|
513
668
|
}
|
|
@@ -515,24 +670,34 @@ Napi::Value call_stop_fax(const Napi::CallbackInfo& info) {
|
|
|
515
670
|
return env.Null();
|
|
516
671
|
}
|
|
517
672
|
|
|
518
|
-
Napi::Value call_get_stream_stat(const Napi::CallbackInfo&
|
|
673
|
+
Napi::Value call_get_stream_stat(const Napi::CallbackInfo &info) {
|
|
519
674
|
Napi::Env env = info.Env();
|
|
520
675
|
|
|
521
|
-
if (info.Length() !=
|
|
522
|
-
Napi::Error::New(env,
|
|
676
|
+
if (info.Length() != 2) {
|
|
677
|
+
Napi::Error::New(env,
|
|
678
|
+
"Wrong number of arguments. Expected: call_id, params")
|
|
679
|
+
.ThrowAsJavaScriptException();
|
|
523
680
|
return env.Null();
|
|
524
681
|
}
|
|
525
682
|
|
|
526
683
|
if (!info[0].IsNumber()) {
|
|
527
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
684
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
685
|
+
.ThrowAsJavaScriptException();
|
|
528
686
|
return env.Null();
|
|
529
687
|
}
|
|
530
688
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
531
689
|
|
|
690
|
+
if (!info[1].IsString()) {
|
|
691
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
692
|
+
.ThrowAsJavaScriptException();
|
|
693
|
+
return env.Null();
|
|
694
|
+
}
|
|
695
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
696
|
+
|
|
532
697
|
char out_stats[4096];
|
|
533
|
-
int res = pjw_call_get_stream_stat(call_id, out_stats);
|
|
698
|
+
int res = pjw_call_get_stream_stat(call_id, json.c_str(), out_stats);
|
|
534
699
|
|
|
535
|
-
if(res != 0) {
|
|
700
|
+
if (res != 0) {
|
|
536
701
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
537
702
|
return env.Null();
|
|
538
703
|
}
|
|
@@ -540,23 +705,24 @@ Napi::Value call_get_stream_stat(const Napi::CallbackInfo& info) {
|
|
|
540
705
|
return Napi::String::New(env, out_stats);
|
|
541
706
|
}
|
|
542
707
|
|
|
708
|
+
/*
|
|
543
709
|
Napi::Value call_refer(const Napi::CallbackInfo& info) {
|
|
544
710
|
Napi::Env env = info.Env();
|
|
545
711
|
|
|
546
712
|
if (info.Length() != 2) {
|
|
547
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id,
|
|
548
|
-
|
|
713
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id,
|
|
714
|
+
params.").ThrowAsJavaScriptException(); return env.Null();
|
|
549
715
|
}
|
|
550
716
|
|
|
551
717
|
if (!info[0].IsNumber()) {
|
|
552
|
-
Napi::TypeError::New(env, "call_id must be
|
|
553
|
-
|
|
718
|
+
Napi::TypeError::New(env, "call_id must be
|
|
719
|
+
number.").ThrowAsJavaScriptException(); return env.Null();
|
|
554
720
|
}
|
|
555
721
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
556
|
-
|
|
722
|
+
|
|
557
723
|
if (!info[1].IsString()) {
|
|
558
|
-
Napi::TypeError::New(env, "params must be a JSON
|
|
559
|
-
|
|
724
|
+
Napi::TypeError::New(env, "params must be a JSON
|
|
725
|
+
string.").ThrowAsJavaScriptException(); return env.Null();
|
|
560
726
|
}
|
|
561
727
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
562
728
|
|
|
@@ -571,29 +737,36 @@ Napi::Value call_refer(const Napi::CallbackInfo& info) {
|
|
|
571
737
|
|
|
572
738
|
return Napi::Number::New(env, out_subscription_id);
|
|
573
739
|
}
|
|
740
|
+
*/
|
|
574
741
|
|
|
575
|
-
Napi::Value call_get_info(const Napi::CallbackInfo&
|
|
742
|
+
Napi::Value call_get_info(const Napi::CallbackInfo &info) {
|
|
576
743
|
Napi::Env env = info.Env();
|
|
577
744
|
|
|
578
745
|
if (info.Length() != 2) {
|
|
579
|
-
Napi::Error::New(
|
|
746
|
+
Napi::Error::New(
|
|
747
|
+
env, "Wrong number of arguments. Expected: call_id, required_info")
|
|
748
|
+
.ThrowAsJavaScriptException();
|
|
580
749
|
return env.Null();
|
|
581
750
|
}
|
|
582
751
|
|
|
583
752
|
if (!info[0].IsNumber()) {
|
|
584
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
753
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
754
|
+
.ThrowAsJavaScriptException();
|
|
585
755
|
return env.Null();
|
|
586
756
|
}
|
|
587
757
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
588
|
-
|
|
758
|
+
|
|
589
759
|
if (!info[1].IsString()) {
|
|
590
|
-
Napi::TypeError::New(env, "required_info must be string.")
|
|
760
|
+
Napi::TypeError::New(env, "required_info must be string.")
|
|
761
|
+
.ThrowAsJavaScriptException();
|
|
591
762
|
return env.Null();
|
|
592
763
|
}
|
|
593
764
|
string required_info = info[1].As<Napi::String>().Utf8Value();
|
|
594
765
|
|
|
595
|
-
if(required_info != "Call-ID" && required_info != "RemoteMediaEndPoint") {
|
|
596
|
-
Napi::TypeError::New(
|
|
766
|
+
if (required_info != "Call-ID" && required_info != "RemoteMediaEndPoint") {
|
|
767
|
+
Napi::TypeError::New(
|
|
768
|
+
env, "required_info must be 'Call-ID' or 'RemoteMediaEndPoint'.")
|
|
769
|
+
.ThrowAsJavaScriptException();
|
|
597
770
|
return env.Null();
|
|
598
771
|
}
|
|
599
772
|
|
|
@@ -601,7 +774,7 @@ Napi::Value call_get_info(const Napi::CallbackInfo& info) {
|
|
|
601
774
|
|
|
602
775
|
int res = pjw_call_get_info(call_id, required_info.c_str(), out_info);
|
|
603
776
|
|
|
604
|
-
if(res != 0) {
|
|
777
|
+
if (res != 0) {
|
|
605
778
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
606
779
|
return env.Null();
|
|
607
780
|
}
|
|
@@ -609,25 +782,27 @@ Napi::Value call_get_info(const Napi::CallbackInfo& info) {
|
|
|
609
782
|
return Napi::String::New(env, out_info);
|
|
610
783
|
}
|
|
611
784
|
|
|
612
|
-
Napi::Value call_gen_string_replaces(const Napi::CallbackInfo&
|
|
785
|
+
Napi::Value call_gen_string_replaces(const Napi::CallbackInfo &info) {
|
|
613
786
|
Napi::Env env = info.Env();
|
|
614
787
|
|
|
615
788
|
if (info.Length() != 1) {
|
|
616
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id")
|
|
789
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id")
|
|
790
|
+
.ThrowAsJavaScriptException();
|
|
617
791
|
return env.Null();
|
|
618
792
|
}
|
|
619
793
|
|
|
620
794
|
if (!info[0].IsNumber()) {
|
|
621
|
-
Napi::TypeError::New(env, "call_id must be number.")
|
|
795
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
796
|
+
.ThrowAsJavaScriptException();
|
|
622
797
|
return env.Null();
|
|
623
798
|
}
|
|
624
799
|
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
625
|
-
|
|
800
|
+
|
|
626
801
|
char out_replaces[4096];
|
|
627
802
|
|
|
628
803
|
int res = pjw_call_gen_string_replaces(call_id, out_replaces);
|
|
629
804
|
|
|
630
|
-
if(res != 0) {
|
|
805
|
+
if (res != 0) {
|
|
631
806
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
632
807
|
return env.Null();
|
|
633
808
|
}
|
|
@@ -635,39 +810,32 @@ Napi::Value call_gen_string_replaces(const Napi::CallbackInfo& info) {
|
|
|
635
810
|
return Napi::String::New(env, out_replaces);
|
|
636
811
|
}
|
|
637
812
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
Napi::Value dtmf_aggregation_on(const Napi::CallbackInfo& info) {
|
|
813
|
+
Napi::Value call_send_tcp_msg(const Napi::CallbackInfo &info) {
|
|
641
814
|
Napi::Env env = info.Env();
|
|
642
815
|
|
|
643
|
-
if (info.Length() !=
|
|
644
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected:
|
|
816
|
+
if (info.Length() != 2) {
|
|
817
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: call_id, params")
|
|
818
|
+
.ThrowAsJavaScriptException();
|
|
645
819
|
return env.Null();
|
|
646
820
|
}
|
|
647
821
|
|
|
648
822
|
if (!info[0].IsNumber()) {
|
|
649
|
-
Napi::TypeError::New(env, "
|
|
823
|
+
Napi::TypeError::New(env, "call_id must be number.")
|
|
824
|
+
.ThrowAsJavaScriptException();
|
|
650
825
|
return env.Null();
|
|
651
826
|
}
|
|
652
|
-
int
|
|
653
|
-
|
|
654
|
-
int res = pjw_dtmf_aggregation_on(inter_digit_timer);
|
|
827
|
+
int call_id = info[0].As<Napi::Number>().Int32Value();
|
|
655
828
|
|
|
656
|
-
if(
|
|
657
|
-
Napi::
|
|
829
|
+
if (!info[1].IsString()) {
|
|
830
|
+
Napi::TypeError::New(env, "params must be a JSON string.")
|
|
831
|
+
.ThrowAsJavaScriptException();
|
|
658
832
|
return env.Null();
|
|
659
833
|
}
|
|
834
|
+
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
660
835
|
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
Napi::Value dtmf_aggregation_off(const Napi::CallbackInfo& info) {
|
|
666
|
-
Napi::Env env = info.Env();
|
|
836
|
+
int res = pjw_call_send_tcp_msg(call_id, json.c_str());
|
|
667
837
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if(res != 0) {
|
|
838
|
+
if (res != 0) {
|
|
671
839
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
672
840
|
return env.Null();
|
|
673
841
|
}
|
|
@@ -676,39 +844,26 @@ Napi::Value dtmf_aggregation_off(const Napi::CallbackInfo& info) {
|
|
|
676
844
|
}
|
|
677
845
|
|
|
678
846
|
|
|
679
|
-
Napi::Value
|
|
847
|
+
Napi::Value dtmf_aggregation_on(const Napi::CallbackInfo &info) {
|
|
680
848
|
Napi::Env env = info.Env();
|
|
681
849
|
|
|
682
|
-
if (info.Length() !=
|
|
683
|
-
Napi::Error::New(env,
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (!info[0].IsString()) {
|
|
688
|
-
Napi::TypeError::New(env, "dev must be string.").ThrowAsJavaScriptException();
|
|
689
|
-
return env.Null();
|
|
690
|
-
}
|
|
691
|
-
string dev = info[0].As<Napi::String>().Utf8Value();
|
|
692
|
-
|
|
693
|
-
if (dev.length() == 0) {
|
|
694
|
-
Napi::Error::New(env, "dev is invalid (blank string)").ThrowAsJavaScriptException();
|
|
695
|
-
return env.Null();
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
if (!info[1].IsString()) {
|
|
699
|
-
Napi::TypeError::New(env, "pcap_file must be string.").ThrowAsJavaScriptException();
|
|
850
|
+
if (info.Length() != 1) {
|
|
851
|
+
Napi::Error::New(env,
|
|
852
|
+
"Wrong number of arguments. Expected: inter_digit_timer")
|
|
853
|
+
.ThrowAsJavaScriptException();
|
|
700
854
|
return env.Null();
|
|
701
855
|
}
|
|
702
|
-
string pcap_file = info[1].As<Napi::String>().Utf8Value();
|
|
703
856
|
|
|
704
|
-
if (
|
|
705
|
-
Napi::
|
|
857
|
+
if (!info[0].IsNumber()) {
|
|
858
|
+
Napi::TypeError::New(env, "inter_digit_timer must be number.")
|
|
859
|
+
.ThrowAsJavaScriptException();
|
|
706
860
|
return env.Null();
|
|
707
861
|
}
|
|
862
|
+
int inter_digit_timer = info[0].As<Napi::Number>().Int32Value();
|
|
708
863
|
|
|
709
|
-
int res =
|
|
864
|
+
int res = pjw_dtmf_aggregation_on(inter_digit_timer);
|
|
710
865
|
|
|
711
|
-
if(res != 0) {
|
|
866
|
+
if (res != 0) {
|
|
712
867
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
713
868
|
return env.Null();
|
|
714
869
|
}
|
|
@@ -716,12 +871,12 @@ Napi::Value packetdump_start(const Napi::CallbackInfo& info) {
|
|
|
716
871
|
return env.Null();
|
|
717
872
|
}
|
|
718
873
|
|
|
719
|
-
Napi::Value
|
|
874
|
+
Napi::Value dtmf_aggregation_off(const Napi::CallbackInfo &info) {
|
|
720
875
|
Napi::Env env = info.Env();
|
|
721
876
|
|
|
722
|
-
int res =
|
|
877
|
+
int res = pjw_dtmf_aggregation_off();
|
|
723
878
|
|
|
724
|
-
if(res != 0) {
|
|
879
|
+
if (res != 0) {
|
|
725
880
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
726
881
|
return env.Null();
|
|
727
882
|
}
|
|
@@ -729,13 +884,13 @@ Napi::Value packetdump_stop(const Napi::CallbackInfo& info) {
|
|
|
729
884
|
return env.Null();
|
|
730
885
|
}
|
|
731
886
|
|
|
732
|
-
Napi::Value get_codecs(const Napi::CallbackInfo&
|
|
887
|
+
Napi::Value get_codecs(const Napi::CallbackInfo &info) {
|
|
733
888
|
Napi::Env env = info.Env();
|
|
734
889
|
|
|
735
890
|
char out_codecs[4096];
|
|
736
891
|
int res = pjw_get_codecs(out_codecs);
|
|
737
892
|
|
|
738
|
-
if(res != 0) {
|
|
893
|
+
if (res != 0) {
|
|
739
894
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
740
895
|
return env.Null();
|
|
741
896
|
}
|
|
@@ -743,23 +898,25 @@ Napi::Value get_codecs(const Napi::CallbackInfo& info) {
|
|
|
743
898
|
return Napi::String::New(env, out_codecs);
|
|
744
899
|
}
|
|
745
900
|
|
|
746
|
-
Napi::Value set_codecs(const Napi::CallbackInfo&
|
|
901
|
+
Napi::Value set_codecs(const Napi::CallbackInfo &info) {
|
|
747
902
|
Napi::Env env = info.Env();
|
|
748
903
|
|
|
749
904
|
if (info.Length() != 1) {
|
|
750
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: codec_info")
|
|
905
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: codec_info")
|
|
906
|
+
.ThrowAsJavaScriptException();
|
|
751
907
|
return env.Null();
|
|
752
908
|
}
|
|
753
909
|
|
|
754
910
|
if (!info[0].IsString()) {
|
|
755
|
-
Napi::TypeError::New(env, "codec_info must be string.")
|
|
911
|
+
Napi::TypeError::New(env, "codec_info must be string.")
|
|
912
|
+
.ThrowAsJavaScriptException();
|
|
756
913
|
return env.Null();
|
|
757
914
|
}
|
|
758
915
|
string codec_info = info[0].As<Napi::String>().Utf8Value();
|
|
759
916
|
|
|
760
917
|
int res = pjw_set_codecs(codec_info.c_str());
|
|
761
918
|
|
|
762
|
-
if(res != 0) {
|
|
919
|
+
if (res != 0) {
|
|
763
920
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
764
921
|
return env.Null();
|
|
765
922
|
}
|
|
@@ -767,29 +924,34 @@ Napi::Value set_codecs(const Napi::CallbackInfo& info) {
|
|
|
767
924
|
return env.Null();
|
|
768
925
|
}
|
|
769
926
|
|
|
770
|
-
Napi::Value notify(const Napi::CallbackInfo&
|
|
927
|
+
Napi::Value notify(const Napi::CallbackInfo &info) {
|
|
771
928
|
Napi::Env env = info.Env();
|
|
772
929
|
|
|
773
930
|
if (info.Length() != 2) {
|
|
774
|
-
Napi::Error::New(
|
|
931
|
+
Napi::Error::New(
|
|
932
|
+
env, "Wrong number of arguments. Expected: subscriber_id, params.")
|
|
933
|
+
.ThrowAsJavaScriptException();
|
|
775
934
|
return env.Null();
|
|
776
935
|
}
|
|
777
936
|
|
|
778
937
|
if (!info[0].IsNumber()) {
|
|
779
|
-
Napi::TypeError::New(env, "subscriber_id must be number.")
|
|
938
|
+
Napi::TypeError::New(env, "subscriber_id must be number.")
|
|
939
|
+
.ThrowAsJavaScriptException();
|
|
780
940
|
return env.Null();
|
|
781
941
|
}
|
|
782
942
|
int subscriber_id = info[0].As<Napi::Number>().Int32Value();
|
|
783
|
-
|
|
943
|
+
|
|
784
944
|
if (!info[1].IsString()) {
|
|
785
|
-
Napi::TypeError::New(env,
|
|
945
|
+
Napi::TypeError::New(env,
|
|
946
|
+
"Wrong argument type: params must be a JSON string.")
|
|
947
|
+
.ThrowAsJavaScriptException();
|
|
786
948
|
return env.Null();
|
|
787
949
|
}
|
|
788
950
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
789
951
|
|
|
790
952
|
int res = pjw_notify(subscriber_id, json.c_str());
|
|
791
953
|
|
|
792
|
-
if(res != 0) {
|
|
954
|
+
if (res != 0) {
|
|
793
955
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
794
956
|
return env.Null();
|
|
795
957
|
}
|
|
@@ -797,29 +959,34 @@ Napi::Value notify(const Napi::CallbackInfo& info) {
|
|
|
797
959
|
return env.Null();
|
|
798
960
|
}
|
|
799
961
|
|
|
800
|
-
Napi::Value notify_xfer(const Napi::CallbackInfo&
|
|
962
|
+
Napi::Value notify_xfer(const Napi::CallbackInfo &info) {
|
|
801
963
|
Napi::Env env = info.Env();
|
|
802
964
|
|
|
803
965
|
if (info.Length() != 2) {
|
|
804
|
-
Napi::Error::New(
|
|
966
|
+
Napi::Error::New(
|
|
967
|
+
env, "Wrong number of arguments. Expected: subscriber_id, params")
|
|
968
|
+
.ThrowAsJavaScriptException();
|
|
805
969
|
return env.Null();
|
|
806
970
|
}
|
|
807
971
|
|
|
808
972
|
if (!info[0].IsNumber()) {
|
|
809
|
-
Napi::TypeError::New(env, "subscriber_id must be number.")
|
|
973
|
+
Napi::TypeError::New(env, "subscriber_id must be number.")
|
|
974
|
+
.ThrowAsJavaScriptException();
|
|
810
975
|
return env.Null();
|
|
811
976
|
}
|
|
812
977
|
int subscriber_id = info[0].As<Napi::Number>().Int32Value();
|
|
813
|
-
|
|
978
|
+
|
|
814
979
|
if (!info[1].IsString()) {
|
|
815
|
-
Napi::TypeError::New(env,
|
|
980
|
+
Napi::TypeError::New(env,
|
|
981
|
+
"Wrong argument type: params must be a JSON string.")
|
|
982
|
+
.ThrowAsJavaScriptException();
|
|
816
983
|
return env.Null();
|
|
817
984
|
}
|
|
818
985
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
819
986
|
|
|
820
987
|
int res = pjw_notify_xfer(subscriber_id, json.c_str());
|
|
821
988
|
|
|
822
|
-
if(res != 0) {
|
|
989
|
+
if (res != 0) {
|
|
823
990
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
824
991
|
return env.Null();
|
|
825
992
|
}
|
|
@@ -827,29 +994,32 @@ Napi::Value notify_xfer(const Napi::CallbackInfo& info) {
|
|
|
827
994
|
return env.Null();
|
|
828
995
|
}
|
|
829
996
|
|
|
830
|
-
Napi::Value register_pkg(const Napi::CallbackInfo&
|
|
997
|
+
Napi::Value register_pkg(const Napi::CallbackInfo &info) {
|
|
831
998
|
Napi::Env env = info.Env();
|
|
832
999
|
|
|
833
1000
|
if (info.Length() != 2) {
|
|
834
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: event, accept")
|
|
1001
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: event, accept")
|
|
1002
|
+
.ThrowAsJavaScriptException();
|
|
835
1003
|
return env.Null();
|
|
836
1004
|
}
|
|
837
1005
|
|
|
838
1006
|
if (!info[0].IsString()) {
|
|
839
|
-
Napi::TypeError::New(env, "event must be string.")
|
|
1007
|
+
Napi::TypeError::New(env, "event must be string.")
|
|
1008
|
+
.ThrowAsJavaScriptException();
|
|
840
1009
|
return env.Null();
|
|
841
1010
|
}
|
|
842
1011
|
string event = info[0].As<Napi::String>().Utf8Value();
|
|
843
1012
|
|
|
844
1013
|
if (!info[1].IsString()) {
|
|
845
|
-
Napi::TypeError::New(env, "accept must be string.")
|
|
1014
|
+
Napi::TypeError::New(env, "accept must be string.")
|
|
1015
|
+
.ThrowAsJavaScriptException();
|
|
846
1016
|
return env.Null();
|
|
847
1017
|
}
|
|
848
1018
|
string accept = info[1].As<Napi::String>().Utf8Value();
|
|
849
1019
|
|
|
850
1020
|
int res = pjw_register_pkg(event.c_str(), accept.c_str());
|
|
851
1021
|
|
|
852
|
-
if(res != 0) {
|
|
1022
|
+
if (res != 0) {
|
|
853
1023
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
854
1024
|
return env.Null();
|
|
855
1025
|
}
|
|
@@ -857,31 +1027,37 @@ Napi::Value register_pkg(const Napi::CallbackInfo& info) {
|
|
|
857
1027
|
return env.Null();
|
|
858
1028
|
}
|
|
859
1029
|
|
|
860
|
-
Napi::Value subscription_create(const Napi::CallbackInfo&
|
|
1030
|
+
Napi::Value subscription_create(const Napi::CallbackInfo &info) {
|
|
861
1031
|
Napi::Env env = info.Env();
|
|
862
1032
|
|
|
863
1033
|
if (info.Length() != 2) {
|
|
864
|
-
Napi::Error::New(
|
|
1034
|
+
Napi::Error::New(
|
|
1035
|
+
env, "Wrong number of arguments. Expected: transport_id, params.")
|
|
1036
|
+
.ThrowAsJavaScriptException();
|
|
865
1037
|
return env.Null();
|
|
866
1038
|
}
|
|
867
1039
|
|
|
868
1040
|
if (!info[0].IsNumber()) {
|
|
869
|
-
Napi::TypeError::New(env, "transport_id must be number.")
|
|
1041
|
+
Napi::TypeError::New(env, "transport_id must be number.")
|
|
1042
|
+
.ThrowAsJavaScriptException();
|
|
870
1043
|
return env.Null();
|
|
871
1044
|
}
|
|
872
1045
|
int transport_id = info[0].As<Napi::Number>().Int32Value();
|
|
873
|
-
|
|
1046
|
+
|
|
874
1047
|
if (!info[1].IsString()) {
|
|
875
|
-
Napi::TypeError::New(env,
|
|
1048
|
+
Napi::TypeError::New(env,
|
|
1049
|
+
"Wrong argument type: params must be a JSON string.")
|
|
1050
|
+
.ThrowAsJavaScriptException();
|
|
876
1051
|
return env.Null();
|
|
877
1052
|
}
|
|
878
1053
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
879
1054
|
|
|
880
1055
|
long out_subscription_id;
|
|
881
1056
|
|
|
882
|
-
int res =
|
|
1057
|
+
int res =
|
|
1058
|
+
pjw_subscription_create(transport_id, json.c_str(), &out_subscription_id);
|
|
883
1059
|
|
|
884
|
-
if(res != 0) {
|
|
1060
|
+
if (res != 0) {
|
|
885
1061
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
886
1062
|
return env.Null();
|
|
887
1063
|
}
|
|
@@ -889,29 +1065,34 @@ Napi::Value subscription_create(const Napi::CallbackInfo& info) {
|
|
|
889
1065
|
return Napi::Number::New(env, out_subscription_id);
|
|
890
1066
|
}
|
|
891
1067
|
|
|
892
|
-
Napi::Value subscription_subscribe(const Napi::CallbackInfo&
|
|
1068
|
+
Napi::Value subscription_subscribe(const Napi::CallbackInfo &info) {
|
|
893
1069
|
Napi::Env env = info.Env();
|
|
894
1070
|
|
|
895
1071
|
if (info.Length() != 2) {
|
|
896
|
-
Napi::Error::New(
|
|
1072
|
+
Napi::Error::New(
|
|
1073
|
+
env, "Wrong number of arguments. Expected: subscription_id, params")
|
|
1074
|
+
.ThrowAsJavaScriptException();
|
|
897
1075
|
return env.Null();
|
|
898
1076
|
}
|
|
899
1077
|
|
|
900
1078
|
if (!info[0].IsNumber()) {
|
|
901
|
-
Napi::TypeError::New(env, "subscription_id must be number.")
|
|
1079
|
+
Napi::TypeError::New(env, "subscription_id must be number.")
|
|
1080
|
+
.ThrowAsJavaScriptException();
|
|
902
1081
|
return env.Null();
|
|
903
1082
|
}
|
|
904
1083
|
int subscription_id = info[0].As<Napi::Number>().Int32Value();
|
|
905
|
-
|
|
1084
|
+
|
|
906
1085
|
if (!info[1].IsString()) {
|
|
907
|
-
Napi::TypeError::New(env,
|
|
1086
|
+
Napi::TypeError::New(env,
|
|
1087
|
+
"Wrong argument type: params must be a JSON string.")
|
|
1088
|
+
.ThrowAsJavaScriptException();
|
|
908
1089
|
return env.Null();
|
|
909
1090
|
}
|
|
910
1091
|
const string json = info[1].As<Napi::String>().Utf8Value();
|
|
911
1092
|
|
|
912
1093
|
int res = pjw_subscription_subscribe(subscription_id, json.c_str());
|
|
913
1094
|
|
|
914
|
-
if(res != 0) {
|
|
1095
|
+
if (res != 0) {
|
|
915
1096
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
916
1097
|
return env.Null();
|
|
917
1098
|
}
|
|
@@ -919,25 +1100,25 @@ Napi::Value subscription_subscribe(const Napi::CallbackInfo& info) {
|
|
|
919
1100
|
return env.Null();
|
|
920
1101
|
}
|
|
921
1102
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
Napi::Value set_log_level(const Napi::CallbackInfo& info) {
|
|
1103
|
+
Napi::Value set_log_level(const Napi::CallbackInfo &info) {
|
|
925
1104
|
Napi::Env env = info.Env();
|
|
926
1105
|
|
|
927
1106
|
if (info.Length() != 1) {
|
|
928
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: log_level")
|
|
1107
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: log_level")
|
|
1108
|
+
.ThrowAsJavaScriptException();
|
|
929
1109
|
return env.Null();
|
|
930
1110
|
}
|
|
931
1111
|
|
|
932
1112
|
if (!info[0].IsNumber()) {
|
|
933
|
-
Napi::TypeError::New(env, "log_level must be number.")
|
|
1113
|
+
Napi::TypeError::New(env, "log_level must be number.")
|
|
1114
|
+
.ThrowAsJavaScriptException();
|
|
934
1115
|
return env.Null();
|
|
935
1116
|
}
|
|
936
1117
|
int log_level = info[0].As<Napi::Number>().Int32Value();
|
|
937
|
-
|
|
1118
|
+
|
|
938
1119
|
int res = pjw_log_level(log_level);
|
|
939
1120
|
|
|
940
|
-
if(res != 0) {
|
|
1121
|
+
if (res != 0) {
|
|
941
1122
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
942
1123
|
return env.Null();
|
|
943
1124
|
}
|
|
@@ -945,96 +1126,118 @@ Napi::Value set_log_level(const Napi::CallbackInfo& info) {
|
|
|
945
1126
|
return Napi::Number::New(env, 0);
|
|
946
1127
|
}
|
|
947
1128
|
|
|
948
|
-
|
|
949
|
-
Napi::Value set_flags(const Napi::CallbackInfo& info) {
|
|
1129
|
+
Napi::Value set_flags(const Napi::CallbackInfo &info) {
|
|
950
1130
|
Napi::Env env = info.Env();
|
|
951
1131
|
|
|
952
1132
|
if (info.Length() != 1) {
|
|
953
|
-
Napi::Error::New(env, "Wrong number of arguments. Expected: flags")
|
|
1133
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected: flags")
|
|
1134
|
+
.ThrowAsJavaScriptException();
|
|
954
1135
|
return env.Null();
|
|
955
1136
|
}
|
|
956
1137
|
|
|
957
1138
|
if (!info[0].IsNumber()) {
|
|
958
|
-
Napi::TypeError::New(env, "flags must be number.")
|
|
1139
|
+
Napi::TypeError::New(env, "flags must be number.")
|
|
1140
|
+
.ThrowAsJavaScriptException();
|
|
959
1141
|
return env.Null();
|
|
960
1142
|
}
|
|
961
1143
|
unsigned flags = info[0].As<Napi::Number>().Uint32Value();
|
|
962
|
-
|
|
1144
|
+
|
|
963
1145
|
pjw_set_flags(flags);
|
|
964
1146
|
|
|
965
1147
|
return Napi::Number::New(env, 0);
|
|
966
1148
|
}
|
|
967
1149
|
|
|
1150
|
+
Napi::Value enable_telephone_event(const Napi::CallbackInfo &info) {
|
|
1151
|
+
Napi::Env env = info.Env();
|
|
968
1152
|
|
|
1153
|
+
if (info.Length() != 0) {
|
|
1154
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected zero arguments")
|
|
1155
|
+
.ThrowAsJavaScriptException();
|
|
1156
|
+
return env.Null();
|
|
1157
|
+
}
|
|
969
1158
|
|
|
1159
|
+
pjw_enable_telephone_event();
|
|
970
1160
|
|
|
971
|
-
|
|
972
|
-
|
|
1161
|
+
return Napi::Number::New(env, 0);
|
|
1162
|
+
}
|
|
973
1163
|
|
|
974
|
-
|
|
1164
|
+
Napi::Value disable_telephone_event(const Napi::CallbackInfo &info) {
|
|
1165
|
+
Napi::Env env = info.Env();
|
|
975
1166
|
|
|
976
|
-
|
|
977
|
-
|
|
1167
|
+
if (info.Length() != 0) {
|
|
1168
|
+
Napi::Error::New(env, "Wrong number of arguments. Expected zero arguments")
|
|
1169
|
+
.ThrowAsJavaScriptException();
|
|
1170
|
+
return env.Null();
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
pjw_disable_telephone_event();
|
|
1174
|
+
|
|
1175
|
+
return Napi::Number::New(env, 0);
|
|
978
1176
|
}
|
|
979
1177
|
|
|
980
|
-
|
|
1178
|
+
|
|
1179
|
+
static void CallJs(napi_env napiEnv, napi_value napi_js_cb, void *context,
|
|
1180
|
+
void *data) {
|
|
1181
|
+
Napi::Env env = Napi::Env(napiEnv);
|
|
1182
|
+
|
|
1183
|
+
Napi::Function js_cb = Napi::Value(env, napi_js_cb).As<Napi::Function>();
|
|
1184
|
+
|
|
1185
|
+
Napi::String str = Napi::String::New(env, (char *)data);
|
|
1186
|
+
js_cb.Call(env.Global(), {str});
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
Napi::Value start(const Napi::CallbackInfo &info) {
|
|
981
1190
|
Napi::Env env = info.Env();
|
|
982
1191
|
|
|
983
1192
|
if (info.Length() < 1 || !info[0].IsFunction()) {
|
|
984
|
-
Napi::TypeError::New(env, "Function expected as argument[0]")
|
|
985
|
-
|
|
1193
|
+
Napi::TypeError::New(env, "Function expected as argument[0]")
|
|
1194
|
+
.ThrowAsJavaScriptException();
|
|
1195
|
+
return env.Undefined();
|
|
1196
|
+
;
|
|
986
1197
|
}
|
|
987
1198
|
|
|
988
1199
|
Napi::Function js_cb = info[0].As<Napi::Function>();
|
|
989
1200
|
|
|
990
1201
|
Napi::String name = Napi::String::New(env, "bla");
|
|
991
1202
|
|
|
992
|
-
napi_status status = napi_create_threadsafe_function(
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
NULL,
|
|
999
|
-
NULL,
|
|
1000
|
-
NULL,
|
|
1001
|
-
CallJs,
|
|
1002
|
-
&tsf);
|
|
1003
|
-
if(status != napi_ok) {
|
|
1004
|
-
Napi::TypeError::New(env, "napi_create_threadsafe_function failed").ThrowAsJavaScriptException();
|
|
1005
|
-
return env.Undefined();
|
|
1203
|
+
napi_status status = napi_create_threadsafe_function(
|
|
1204
|
+
env, js_cb, NULL, name, 0, 1, NULL, NULL, NULL, CallJs, &tsf);
|
|
1205
|
+
if (status != napi_ok) {
|
|
1206
|
+
Napi::TypeError::New(env, "napi_create_threadsafe_function failed")
|
|
1207
|
+
.ThrowAsJavaScriptException();
|
|
1208
|
+
return env.Undefined();
|
|
1006
1209
|
}
|
|
1007
1210
|
|
|
1008
|
-
//boost::thread t{poll};
|
|
1211
|
+
// boost::thread t{poll};
|
|
1009
1212
|
|
|
1010
1213
|
return env.Undefined();
|
|
1011
1214
|
}
|
|
1012
1215
|
|
|
1013
|
-
Napi::Value do_poll(const Napi::CallbackInfo&
|
|
1216
|
+
Napi::Value do_poll(const Napi::CallbackInfo &info) {
|
|
1014
1217
|
Napi::Env env = info.Env();
|
|
1015
1218
|
|
|
1016
1219
|
char buf[4096];
|
|
1017
1220
|
int res = __pjw_poll(buf);
|
|
1018
|
-
if(res == 0) {
|
|
1221
|
+
if (res == 0) {
|
|
1019
1222
|
return Napi::String::New(env, buf);
|
|
1020
1223
|
} else {
|
|
1021
1224
|
return env.Null();
|
|
1022
|
-
}
|
|
1225
|
+
}
|
|
1023
1226
|
}
|
|
1024
|
-
|
|
1025
|
-
Napi::Value shutdown_(const Napi::CallbackInfo&
|
|
1227
|
+
|
|
1228
|
+
Napi::Value shutdown_(const Napi::CallbackInfo &info) {
|
|
1026
1229
|
Napi::Env env = info.Env();
|
|
1027
1230
|
|
|
1028
1231
|
int res = __pjw_shutdown();
|
|
1029
1232
|
|
|
1030
|
-
if(res != 0) {
|
|
1233
|
+
if (res != 0) {
|
|
1031
1234
|
Napi::Error::New(env, pjw_get_error()).ThrowAsJavaScriptException();
|
|
1032
1235
|
return env.Null();
|
|
1033
1236
|
}
|
|
1034
1237
|
|
|
1035
1238
|
return env.Null();
|
|
1036
1239
|
}
|
|
1037
|
-
|
|
1240
|
+
|
|
1038
1241
|
Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
1039
1242
|
int i = __pjw_init();
|
|
1040
1243
|
printf("__pjw_init res=%i\n", i);
|
|
@@ -1045,7 +1248,11 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
1045
1248
|
|
|
1046
1249
|
exports.Set("account_create", Napi::Function::New(env, account_create));
|
|
1047
1250
|
exports.Set("account_register", Napi::Function::New(env, account_register));
|
|
1048
|
-
exports.Set("account_unregister",
|
|
1251
|
+
exports.Set("account_unregister",
|
|
1252
|
+
Napi::Function::New(env, account_unregister));
|
|
1253
|
+
|
|
1254
|
+
exports.Set("request_create", Napi::Function::New(env, request_create));
|
|
1255
|
+
exports.Set("request_respond", Napi::Function::New(env, request_respond));
|
|
1049
1256
|
|
|
1050
1257
|
exports.Set("call_create", Napi::Function::New(env, call_create));
|
|
1051
1258
|
exports.Set("call_respond", Napi::Function::New(env, call_respond));
|
|
@@ -1053,27 +1260,35 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
1053
1260
|
exports.Set("call_send_dtmf", Napi::Function::New(env, call_send_dtmf));
|
|
1054
1261
|
exports.Set("call_reinvite", Napi::Function::New(env, call_reinvite));
|
|
1055
1262
|
exports.Set("call_send_request", Napi::Function::New(env, call_send_request));
|
|
1056
|
-
exports.Set("call_start_record_wav",
|
|
1057
|
-
|
|
1263
|
+
exports.Set("call_start_record_wav",
|
|
1264
|
+
Napi::Function::New(env, call_start_record_wav));
|
|
1265
|
+
exports.Set("call_start_play_wav",
|
|
1266
|
+
Napi::Function::New(env, call_start_play_wav));
|
|
1058
1267
|
exports.Set("call_start_fax", Napi::Function::New(env, call_start_fax));
|
|
1059
|
-
exports.Set("call_stop_record_wav",
|
|
1060
|
-
|
|
1268
|
+
exports.Set("call_stop_record_wav",
|
|
1269
|
+
Napi::Function::New(env, call_stop_record_wav));
|
|
1270
|
+
exports.Set("call_stop_play_wav",
|
|
1271
|
+
Napi::Function::New(env, call_stop_play_wav));
|
|
1061
1272
|
exports.Set("call_stop_fax", Napi::Function::New(env, call_stop_fax));
|
|
1062
|
-
exports.Set("call_get_stream_stat",
|
|
1063
|
-
|
|
1273
|
+
exports.Set("call_get_stream_stat",
|
|
1274
|
+
Napi::Function::New(env, call_get_stream_stat));
|
|
1275
|
+
// exports.Set("call_refer", Napi::Function::New(env, call_refer));
|
|
1064
1276
|
exports.Set("call_get_info", Napi::Function::New(env, call_get_info));
|
|
1065
|
-
exports.Set("call_gen_string_replaces",
|
|
1277
|
+
exports.Set("call_gen_string_replaces",
|
|
1278
|
+
Napi::Function::New(env, call_gen_string_replaces));
|
|
1279
|
+
|
|
1280
|
+
exports.Set("call_send_tcp_msg",
|
|
1281
|
+
Napi::Function::New(env, call_send_tcp_msg));
|
|
1066
1282
|
|
|
1067
1283
|
exports.Set("set_log_level", Napi::Function::New(env, set_log_level));
|
|
1068
1284
|
|
|
1069
1285
|
exports.Set("do_poll", Napi::Function::New(env, do_poll));
|
|
1070
1286
|
exports.Set("shutdown", Napi::Function::New(env, shutdown_));
|
|
1071
1287
|
|
|
1072
|
-
exports.Set("dtmf_aggregation_on",
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
exports.Set("packetdump_stop", Napi::Function::New(env, packetdump_stop));
|
|
1288
|
+
exports.Set("dtmf_aggregation_on",
|
|
1289
|
+
Napi::Function::New(env, dtmf_aggregation_on));
|
|
1290
|
+
exports.Set("dtmf_aggregation_off",
|
|
1291
|
+
Napi::Function::New(env, dtmf_aggregation_off));
|
|
1077
1292
|
|
|
1078
1293
|
exports.Set("get_codecs", Napi::Function::New(env, get_codecs));
|
|
1079
1294
|
exports.Set("set_codecs", Napi::Function::New(env, set_codecs));
|
|
@@ -1083,11 +1298,16 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
|
|
1083
1298
|
|
|
1084
1299
|
exports.Set("register_pkg", Napi::Function::New(env, register_pkg));
|
|
1085
1300
|
|
|
1086
|
-
exports.Set("subscription_create",
|
|
1087
|
-
|
|
1301
|
+
exports.Set("subscription_create",
|
|
1302
|
+
Napi::Function::New(env, subscription_create));
|
|
1303
|
+
exports.Set("subscription_subscribe",
|
|
1304
|
+
Napi::Function::New(env, subscription_subscribe));
|
|
1088
1305
|
|
|
1089
1306
|
exports.Set("set_flags", Napi::Function::New(env, set_flags));
|
|
1090
1307
|
|
|
1308
|
+
exports.Set("disable_telephone_event", Napi::Function::New(env, disable_telephone_event));
|
|
1309
|
+
exports.Set("enable_telephone_event", Napi::Function::New(env, enable_telephone_event));
|
|
1310
|
+
|
|
1091
1311
|
return exports;
|
|
1092
1312
|
}
|
|
1093
1313
|
|