-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIPml.js
1808 lines (1633 loc) · 82 KB
/
SIPml.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
* License: GPLv3
* This file is part of Open Source sipML5 solution <http://www.sipml5.org>
*/
/**
@fileoverview This is SIPML5 "library" contains a lot of classes and functions.
@name sipML5 API
@author Doubango Telecom <http://www.doubango.org>
@version 1.0
*/
/**
@namespace
@description Root namesapce.
*/
SIPml = {};
/** @private */SIPml.b_initialized = false;
/** @private */SIPml.b_initializing = false;
/** @private */SIPml.s_navigator_friendly_name = 'unknown';
/** @private */SIPml.b_navigator_outdated = false;
/** @private */SIPml.s_navigator_version = 'unknown';
/** @private */SIPml.s_system_friendly_name = 'unknown';
/** @private */SIPml.b_webrtc4all_plugin_outdated = false;
/** @private */SIPml.b_webrtc4all_supported = false;
/** @private */SIPml.s_webrtc4all_version = 'unknown';
/** @private */SIPml.b_webrtc_supported = false;
/** @private */SIPml.o_timer_initialized = undefined;
/**
Gets the version name of the installed <a href="http://code.google.com/p/webrtc4all/">webrtc4all plugin</a>.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} Version name (e.g. '1.12.756')
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getWebRtc4AllVersion = function() {
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_webrtc4all_version;
};
/**
Gets the web browser version (e.g. <i>'1.5.beta'</i>).
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} The the web browser version.
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getNavigatorVersion = function() {
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_navigator_version;
};
/**
Gets the web browser friendly name (e.g. <i>'chrome'</i>, <i>'firefox'</i>, <i>'safari'</i>, <i>'opera'</i>, <i>'ie'</i> or <i>'netscape'</i>).
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} The web browser friendly name.
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getNavigatorFriendlyName = function() {
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_navigator_friendly_name;
};
/**
Gets the Operating System friendly name (e.g. <i>'windows'</i>, <i>'mac'</i>, <i>'lunix'</i>, <i>'solaris'</i>, <i>'sunos'</i> or <i>'powerpc'</i>).
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {String} The Operating System friendly name.
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.getSystemFriendlyName = function() {
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.s_system_friendly_name;
};
/**
Checks whether the web browser supports WebRTC but is outdated.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if outdated; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isNavigatorOutdated= function () {
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_navigator_outdated;
}
/**
Checks whether the <a href="http://code.google.com/p/webrtc4all/">webrtc4all plugin</a> is outdated or not.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if outdated; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isWebRtc4AllPluginOutdated = function(){
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_webrtc4all_plugin_outdated;
}
/**
Checks whether the <a href="http://code.google.com/p/webrtc4all/">webrtc4all plugin</a> is installed or not.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isWebRtc4AllSupported = function(){
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_webrtc4all_supported;
}
/**
Checks whether WebRTC is supported or not.
You must <a href="#.init">initialize</a> the engine before calling this function.
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isWebRtcSupported = function () {
if(!SIPml.isInitialized()){
throw new Error("ERR_NOT_INITIALIZED: Engine not initialized yet. Please call 'SIPml.init()' first");
}
return SIPml.b_webrtc_supported;
}
/**
Checks whether WebSocket is supported or not.
@static
@returns {Boolean} <i>true</i> if supported; otherwise <i>false</i>
*/
SIPml.isWebSocketSupported = function () {
return tsk_utils_have_websocket();
}
/**
Checks whether the media engine have a valid stream or not. The stream is from <a href="https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia">getUserMedia</a>.
@static
@returns {Boolean} <i>true</i> if the engine have a valid stream; otherwise <i>false</i>
*/
SIPml.haveMediaStream = function () {
return tsk_utils_have_stream();
}
/**
Checks whether the engine is ready to make/receive calls or not. <br />
The engine is ready when:
<ul>
<li>engine is <a href="#.init">initialized</a></li>
<li>webrtc is supported</li>
<li>we got a valid media stream (from <a href="https://developer.mozilla.org/en-US/docs/WebRTC/navigator.getUserMedia">getUserMedia</a>)</li>
</ul>
@static
@returns {Boolean} <i>true</i> if the engine is ready; otherwise <i>false</i>
@throws {ERR_NOT_INITIALIZED} <font color="red">ERR_NOT_INITIALIZED</font> if the engine is not <a href="#.init">initialized</a>.
*/
SIPml.isReady = function () {
return (SIPml.isInitialized() && SIPml.isWebRtcSupported() && SIPml.haveMediaStream());
}
/**
Checks whether the engine is initialized or not. To initialize the stack you must call <a href="#.init">init()</a> function.
@static
@returns {Boolean} <i>true</i> if the engine is initialized; otherwise <i>false</i>
*/
SIPml.isInitialized = function () { return SIPml.b_initialized; }
/**
Initialize the engine. <b>You must call this function before any other.</b>.
@param {CallbackFunction} [readyCallback] Optional callback function to call when the stack finish initializing and become ready.
@param {CallbackFunction} [errorCallback] Optional callback function to call when initialization fails.
@example
SIPml.init(function(e){ console.info('engine is ready'); }, function(e){ console.info('Error: ' + e.message); });
@static
*/
SIPml.init = function (successCallback, errorCallback) {
if (!SIPml.b_initialized && !SIPml.b_initializing) {
SIPml.b_initializing = true;
tsk_utils_init_webrtc();
tsk_utils_log_info('User-Agent=' + (navigator.userAgent || "unknown"));
SIPml.b_webrtc_supported = tsk_utils_have_webrtc();
SIPml.b_webrtc4all_supported = tsk_utils_have_webrtc4all();
SIPml.s_webrtc4all_version = tsk_utils_webrtc4all_get_version();
SIPml.s_navigator_friendly_name = tsk_utils_get_navigator_friendly_name();
SIPml.s_system_friendly_name = tsk_utils_get_system_friendly_name();
// print webrtc4all type and version
if(SIPml.b_webrtc4all_supported){
tsk_utils_log_info("WebRTC type = " + WebRtc4all_GetType() + " version = " + tsk_utils_webrtc4all_get_version());
}
// check webrtc4all version
if (tsk_utils_have_webrtc4all()) {
tsk_utils_log_info("WebRTC type = " + WebRtc4all_GetType() + " version = " + tsk_utils_webrtc4all_get_version());
if (SIPml.s_webrtc4all_version != '1.12.756') {
b_webrtc4all_plugin_outdated = true;
return;
}
}
// prints navigator friendly name
tsk_utils_log_info("Navigator friendly name = " + SIPml.s_navigator_friendly_name);
// gets navigator version
if(SIPml.s_navigator_friendly_name == 'ie'){
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(navigator.userAgent) != null) {
SIPml.s_navigator_version = RegExp.$1;
}
}
// prints OS friendly name
tsk_utils_log_info("OS friendly name = " + SIPml.s_system_friendly_name);
// checks for WebRTC support
if (!tsk_utils_have_webrtc()) {
// is it chrome?
if (SIPml.s_navigator_friendly_name == "chrome") {
SIPml.b_navigator_outdated = true;
return;
}
// for now the plugins (WebRTC4all only works on Windows)
if (SIPml.s_system_friendly_name == 'win' || SIPml.s_system_friendly_name == 'windows') {
// Internet explorer
if (SIPml.s_navigator_friendly_name == 'ie') {
// Check for IE version
var rv = -1;
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null) {
rv = parseFloat(RegExp.$1);
}
if (rv < 9.0) {
SIPml.b_navigator_outdated = true;
return;
}
// break page loading ('window.location' won't stop JS execution)
if (!tsk_utils_have_webrtc4all()) {
return;
}
}
}
}
SIPml.o_timer_initialized = setInterval(function () {
if (SIPml.haveMediaStream() /* must use function */ && SIPml.b_webrtc_supported) {
SIPml.b_initialized = true;
SIPml.b_initializing = false;
clearInterval(SIPml.o_timer_initialized);
if(successCallback){
successCallback({});
}
}
}, 500);
}
}
// ================================== SIPml.EventTarget ==========================================
/**
@constructor
Defines an event target. You sould never create an event target object.
*/
SIPml.EventTarget = function () {
this.ao_listeners = [];
}
/**
Adds an event listener to the target object. <br /><br />
<table border="1">
<tr>
<td><b>Target classes<b></td>
<td><b>Supported event types<b></td>
<td><b>Raised event object<b></td>
<td><b>Remarques<b></td>
</tr>
<tr>
<td><a href="SIPml.Stack.html" name="SIPml.EventTarget.Stack">SIPml.Stack</a></td>
<td>
<b>*</b><br/> starting<br/> started<br/> stopping<br/> stopped<br/> failed_to_start<br/> failed_to_stop<br/> i_new_call<br /> i_new_message<br />
m_permission_requested<br/> m_permission_accepted<br/> m_permission_refused
</td>
<td><a href="SIPml.Stack.Event.html">SIPml.Stack.Event</a></td>
<td>'*' is used to listen for all events</td>
</tr>
<tr>
<td>
<a href="SIPml.Session.html" name="SIPml.EventTarget.Session">SIPml.Session</a>
<ul>
<li><a href="SIPml.Session.Call.html">SIPml.Session.Call</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Message</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Registration</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Subscribe</a></li>
<li><a href="SIPml.Session.Message.html">SIPml.Session.Publish</a></li>
<ul>
</td>
<td><b>*</b><br/> connecting<br/> connected<br/> terminating<br/> terminated<br/>
i_ao_request<br />
media_added<br/> media_removed<br/>
i_request<br/> o_request<br/> cancelled_request<br/> sent_request<br/>
transport_error<br/> global_error<br/> message_error<br/> webrtc_error
</td>
<td><a href="SIPml.Session.Event.html">SIPml.Session.Event</a></td>
<td>'*' is used to listen for all events<br /></td>
</tr>
<tr>
<td><a href="SIPml.Session.Call.html" name="SIPml.EventTarget.Session.Call">SIPml.Session.Call</a></td>
<td>
m_early_media<br/> m_local_hold_ok<br/> m_local_hold_nok<br/> m_local_resume_ok<br/> m_local_resume_nok<br/> m_remote_hold<br/> m_remote_resume<br/>
m_stream_video_local_added<br /> m_stream_video_local_removed<br/> m_stream_video_remote_added<br/> m_stream_video_remote_removed <br />
m_stream_audio_local_added<br /> m_stream_audio_local_removed<br/> m_stream_audio_remote_added<br/> m_stream_audio_remote_removed <br />
i_ect_new_call<br/> o_ect_trying<br/> o_ect_accepted<br/> o_ect_completed<br/> i_ect_completed<br/> o_ect_failed<br/> i_ect_failed<br/> o_ect_notify<br/> i_ect_notify<br/> i_ect_requested
</td>
<td><a href="SIPml.Session.Event.html">SIPml.Session.Event</a></td>
<td>borrows all events supported by <a href="SIPml.Session.html">SIPml.Session</a></td>
</tr>
<tr>
<td><a href="SIPml.Session.Subscribe.html" name="SIPml.EventTarget.Session.Subscribe">SIPml.Session.Subscribe</a></td>
<td>
i_notify
</td>
<td><a href="SIPml.Session.Event.html">SIPml.Session.Event</a></td>
<td>borrows all events supported by <a href="SIPml.Session.html">SIPml.Session</a></td>
</tr>
</table>
@param {String|Array} type The event type/identifier. Must not be null or empty. Use <b>'*'</b> to listen for all events.
@param {function} listener The object that receives a notification when an event of the specified type occurs. This must be an object implementing the <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener">EventListener</a> interface, or simply a JavaScript function.
@example
// listen for a single event
this.addEventListener('started', function(e){
console.info("'started' event fired");
});
// or listen for two or more events
this.addEventListener(['started', 'stopped'], function(e){
console.info("'"+e.type+"' event fired");
});
// or listen for all events
this.addEventListener('*', function(e){
console.info("'"+e.type+"' event fired");
});
@see <a href="#removeEventListener">removeEventListener</a>
@throws {ERR_INVALID_PARAMETER_VALUE|ERR_INVALID_PARAMETER_TYPE} <font color="red">ERR_INVALID_PARAMETER_VALUE</font> | <font color="red">ERR_INVALID_PARAMETER_TYPE</font>
*/
SIPml.EventTarget.prototype.addEventListener = function (o_type, o_listener) {
if (!o_listener) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: 'listener' must not be null");
}
if (!o_type) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: 'type' must not be null");
}
if(!(o_type instanceof String || typeof o_type == "string" || o_type instanceof Array)){
throw new Error("ERR_INVALID_PARAMETER_TYPE: 'type' must be a string or array");
}
if(o_type instanceof Array){
var This = this;
o_type.forEach(function (s_type) {
if (!tsk_string_is_null_or_empty(s_type) && tsk_string_is_string(s_type)) {
This.ao_listeners[s_type] = o_listener;
}
});
}
else{
this.ao_listeners[o_type] = o_listener;
}
}
/**
Removes an event listener from the target object.
@param {String} type The event type/identifier to stop listening for.
@see <a href="#addEventListener">addEventListener</a>
@exemple
this.removeEventListener('started');
*/
SIPml.EventTarget.prototype.removeEventListener = function (s_type) {
if (tsk_string_is_string(s_type) && !tsk_string_is_null_or_empty(s_type)) {
this.ao_listeners[s_type] = undefined;
}
}
/**
@ignore
@private
@param {Object} event
*/
SIPml.EventTarget.prototype.dispatchEvent = function (o_event) {
var o_listener = (this.ao_listeners[o_event.s_type] || this.ao_listeners['*']);
if (o_listener) {
o_listener.call(this, o_event.o_value);
}
}
// ================================== SIPml.Event ==========================================
/**
SIP event object. You should never create an instance of this class by yourself.
@constructor
@param {String} type The event type or identifier. Please check <a href="SIPml.EventTarget.html#SIPml.EventTarget.Session">this link</a> for more information about all supported session event types.
@param {tsip_event} [event] Private wrapped session object.
@property {String} type The event <a href="SIPml.EventTarget.html#SIPml.EventTarget.Session">type or identifier</a> (e.g. <i>'connected'</i>).
@property {String} description User-friendly description in english (e.g. <i>'Session is now connected'</i>).
*/
SIPml.Event = function (s_type, o_event) {
this.type = s_type;
this.description = o_event ? o_event.s_phrase : s_type;
this.o_event = o_event;
}
/**
Gets the SIP response code.
@returns {Integer} The SIP response code (e.g. 404).
*/
SIPml.Event.prototype.getSipResponseCode = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message && o_message.is_response()) {
return o_message.get_response_code();
}
return -1;
}
/**
Gets the SIP content associated to this event. This function could be called to get the content of the incoming SIP message ('i_new_message' event).
@returns {Object} SIP content.
@see <a href="#getContentType">getContentType</a>, <a href="#getContentString">getContentString</a>
*/
SIPml.Event.prototype.getContent = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message) {
return o_message.get_content();
}
return null;
}
/**
Gets the SIP content associated to this event. This function could be called to get the content of the incoming SIP message ('i_new_message' event).
@returns {String} SIP content.
@see <a href="#getContentType">getContentType</a>, <a href="#getContent">getContent</a>
*/
SIPml.Event.prototype.getContentString = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message) {
return o_message.get_content_as_string();
}
return null;
}
/**
Gets the SIP content-type associated to this event. This function could be called to get the content-type of the incoming SIP message ('i_new_message' event).
@returns {Object} SIP content-type.
@see <a href="#getContent">getContent</a>
*/
SIPml.Event.prototype.getContentType = function () {
var o_message = this.o_event ? this.o_event.get_message() : null;
if (o_message) {
return o_message.get_content_type();
}
return null;
}
// ================================== SIPml.Stack ==========================================
/**
Anonymous SIP Stack configuration object.
@namespace SIPml.Stack.Configuration
@name SIPml.Stack.Configuration
@property {String} realm The domain name. Required for stack <a href="SIPml.Stack.html#constructor">constructor</a> but optional when used with <a href="SIPml.Stack.html#setConfiguration">setConfiguration</a>. <br />
Example: <i>example.org</i>
@property {String} impi The authentication name. Required for stack <a href="SIPml.Stack.html#constructor">constructor</a> but optional when used with <a href="SIPml.Stack.html#setConfiguration">setConfiguration</a>.<br />
Example: <i>+33600000000</i> or <i>bob</i>.
@property {string} impu The full SIP uri address. Required for stack <a href="SIPml.Stack.html#constructor">constructor</a> but optional when used with <a href="SIPml.Stack.html#setConfiguration">setConfiguration</a>.<br />
Example: <i>sip:[email protected]</i> or <i>tel:+33600000000</i> or <i>sip:[email protected]</i>
@property {String} [password] The password to use for SIP authentication.<br />
Example: <i>mysecret</i>
@property {String} [display_name] The display name to use in SIP requests. This is the String displayed by the called party for incoming calls. <br />
Example: <i>I Am Legend</i>
@property {String} [websocket_proxy_url] The websocket proxy url to connect to (SIP server or gateway address). If unset the stack will use sipml5.org as host and a random port. You should not set this value unless you know what you're doing.<br />
Example: <i>ws://sipml5.org:5060</i>
@property {String} [outbound_proxy_url] The outbound Proxy URL is used to set the destination IP address and Port to use for all outgoing requests regardless the <i>domain name</i> (a.k.a <i>realm</i>). <br />
This is a good option for developers using a SIP domain name without valid DNS A/NAPTR/SRV records. You should not set this value unless you know what you're doing. <br />
Example: <i>udp://192.168.0.12:5060</i>
@property {Boolean} [enable_rtcweb_breaker] Whether to enable the <a href="http://webrtc2sip.org/#aRTCWebBreaker" target=_blank>RTCWeb Breaker</a> module to allow calling SIP-legacy networks.
Example: <i>true</i>
@property {Object} [events_listener] Object to subscribe to some events.
Example:
<ul>
<li><i>{ events: '*', listener: function(e){} }</i> </li>
<li><i>{ events: 'started', listener: function(e){} }</i></li>
<li><i>{ events: ['started', 'stopped'], listener: function(e){} }</i></li>
</ul>
You can also use <a href="#addEventListener">addEventListener</a> to add listeners to the stack.
@property {Array} [sip_headers] Stack-level SIP headers to add to all outgoing requests. Each header is an object with a <i>name</i> and <i>value</i> fields. <br />
Example: <i>sip_headers: [{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'}, {name: 'Organization', value: 'Doubango Telecom'}]</i>
@example
var configuration = {
realm: 'example.org',
impi: 'bob',
impu: 'sip:[email protected]',
password: 'mysecret', // optional
display_name: 'I Am Legend', // optional
websocket_proxy_url: 'ws://192.168.0.10:5060', // optional
outbound_proxy_url: 'udp://192.168.0.12:5060', // optional
enable_rtcweb_breaker: true, // optional
events_listener: { events: '*', listener: listenerFunc }, //optional
sip_headers: [ //optional
{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'},
{name: 'Organization', value: 'Doubango Telecom'}
]
};
*/
/**
This is the root object used by any other object to make/receive calls, messages or manage presence.
You have to create an instance of this class before anything else.
@extends SIPml.EventTarget
@constructor
@class
@param {SIPml.Stack.Configuration} configuration Configuration object. Could be updated later using <a href="#setConfiguration">setConfiguration</a>.
@throws {ERR_INVALID_PARAMETER_VALUE|ERR_INVALID_PARAMETER_TYPE} <font color="red">ERR_INVALID_PARAMETER_VALUE</font> | <font color="red">ERR_INVALID_PARAMETER_TYPE</font>
@example
var listenerFunc = function(e){
console.info('stack event = ' + e.type);
// Please check <a href="SIPml.EventTarget.html#SIPml.EventTarget.Stack">this link</a> for more information on all supported events.
}
var o_stack = new SIPml.Stack({
realm: 'example.org',
impi: 'bob',
impu: 'sip:[email protected]',
password: 'mysecret', // optional
display_name: 'I Am Legend', // optional
websocket_proxy_url: 'ws://192.168.0.10:5060', // optional
outbound_proxy_url: 'udp://192.168.0.12:5060', // optional
enable_rtcweb_breaker: true, // optional
events_listener: { events: '*', listener: listenerFunc }, //optional
sip_headers: [ //optional
{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'},
{name: 'Organization', value: 'Doubango Telecom'}
]
}
);
@see <a href="#setConfiguration">setConfiguration</a>
*/
SIPml.Stack = function (o_conf) {
SIPml.init();
SIPml.EventTarget.call(this);
/*
members:
- o_stack {tsip_stack}
*/
if (!o_conf) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: null configuration value");
}
if (tsk_string_is_null_or_empty(o_conf.realm)) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.realm + "' is not valid as realm value");
}
if (tsk_string_is_null_or_empty(o_conf.impi)) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.impi + "' is not valid as impi value");
}
if (tsk_string_is_null_or_empty(o_conf.impu)) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.impu + "' is not valid as impu value");
}
// check IMPU validity
var o_impu = tsip_uri.prototype.Parse(o_conf.impu);
if (!o_impu || !o_impu.s_user_name || !o_impu.s_host) {
throw new Error("ERR_INVALID_PARAMETER_VALUE: '" + o_conf.impu + "' is not valid as SIP Uri");
}
var i_port;
var s_proxy;
if (!SIPml.isWebSocketSupported()) {
// port and host will be updated using the result from DNS SRV(NAPTR(realm))
i_port = 5060;
s_proxy = o_conf.realm;
}
else {
// there are at least 5 servers running on the cloud.
// we will connect to one of them and let the balancer to choose the right one (less connected sockets)
// each port can accept up to 65K connections which means that the cloud can manage 325K active connections
// the number of port will be increased or decreased based on the current trafic
// webrtc2sip 1.0 (Resiprocate): 4062, 5062, 6062, 7062 and 8062
// webrtc2sip 2.0 (Doubango):
// WS: 10060, 11060, 12060, 13060, 14060
// WSS: 10062, 11062, 12062, 13062, 14062
//
// Resiprocate version (v1.0) is deprecated but still used until Doubango version is fully tested
// Doubango version (v2.0) is only used if RTCWeb Breaker is enabled and always use secure transport (WSS)
i_port = (o_conf.enable_rtcweb_breaker ? 10062 : 4062) + (((new Date().getTime()) % 5) * 1000);
s_proxy = "sipml5.org";
}
// create the stack
this.o_stack = new tsip_stack(o_conf.realm, o_conf.impi, o_conf.impu, s_proxy, i_port);
this.o_stack.oStack = this;
// set configurations
this.setConfiguration(o_conf);
// listen for stack events
this.o_stack.on_event_stack = function(e) {
var s_type;
switch (e.i_code) {
case tsip_event_code_e.STACK_STARTING: s_type = 'starting'; break;
case tsip_event_code_e.STACK_STARTED: s_type = 'started'; break;
case tsip_event_code_e.STACK_STOPPING: s_type = 'stopping'; break;
case tsip_event_code_e.STACK_STOPPED: s_type = 'stopped'; break;
case tsip_event_code_e.STACK_FAILED_TO_START: s_type = 'failed_to_start'; break;
case tsip_event_code_e.STACK_FAILED_TO_STOP: s_type = 'failed_to_stop'; break;
}
if(s_type){
e.o_stack.oStack.dispatchEvent({ s_type: s_type, o_value: new SIPml.Stack.Event(s_type, e) });
}
}
// listen for dialog events
this.o_stack.on_event_dialog = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if (!oSession) {
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id);
return;
}
switch (e.i_code) {
case tsip_event_code_e.DIALOG_TRANSPORT_ERROR: s_type = 'transport_error'; break;
case tsip_event_code_e.DIALOG_GLOBAL_ERROR: s_type = 'global_error'; break;
case tsip_event_code_e.DIALOG_MESSAGE_ERROR: s_type = 'message_error'; break;
case tsip_event_code_e.DIALOG_WEBRTC_ERROR: s_type = 'webrtc_error'; break;
case tsip_event_code_e.DIALOG_REQUEST_INCOMING: s_type = 'i_request'; break;
case tsip_event_code_e.DIALOG_REQUEST_OUTGOING: s_type = 'o_request'; break;
case tsip_event_code_e.DIALOG_REQUEST_CANCELLED: s_type = 'cancelled_request'; break;
case tsip_event_code_e.DIALOG_REQUEST_SENT: s_type = 'sent_request'; break;
case tsip_event_code_e.DIALOG_MEDIA_ADDED: s_type = 'media_added'; break;
case tsip_event_code_e.DIALOG_MEDIA_REMOVED: s_type = 'media_removed'; break;
case tsip_event_code_e.DIALOG_CONNECTING: s_type = 'connecting'; break;
case tsip_event_code_e.DIALOG_CONNECTED: s_type = 'connected'; break;
case tsip_event_code_e.DIALOG_TERMINATING: s_type = 'terminating'; break;
case tsip_event_code_e.DIALOG_TERMINATED:
{
s_type = 'terminated';
e.o_session.o_stack.oStack.ao_sessions[i_session_id] = undefined;
break;
}
default: break;
}
if (s_type) {
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
}
// listen for MESSAGE events
this.o_stack.on_event_message = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
switch (e.e_message_type) {
case tsip_event_message_type_e.I_MESSAGE: s_type = 'i_new_message'; break;
case tsip_event_message_type_e.AO_MESSAGE: s_type = 'i_ao_request'; break;
}
if (s_type) {
// 'i_new_call' is stack-level event
if (s_type == 'i_new_message') {
var oNewEvent = new SIPml.Stack.Event(s_type, e);
oNewEvent.newSession = new SIPml.Session.Message(e.o_session);
e.o_session.o_stack.oStack.ao_sessions[i_session_id] = oNewEvent.newSession; // save session
e.o_session.o_stack.oStack.dispatchEvent({ s_type: s_type, o_value: oNewEvent});
}
else {
if(oSession){
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
else{
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
}
}
}
};
// listen for PUBLISH events
this.o_stack.on_event_publish = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if(!oSession){
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
return;
}
switch(e.e_publish_type){
case tsip_event_publish_type_e.I_PUBLISH: break;
case tsip_event_publish_type_e.I_UNPUBLISH: break;
case tsip_event_publish_type_e.AO_PUBLISH:
case tsip_event_publish_type_e.AO_UNPUBLISH:
{
s_type = 'i_ao_request';
break;
}
}
if(s_type){
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
}
// listen for SUBSCRIBE events
this.o_stack.on_event_subscribe = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if(!oSession){
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
return;
}
switch(e.e_subscribe_type){
case tsip_event_subscribe_type_e.I_SUBSCRIBE: break;
case tsip_event_subscribe_type_e.I_UNSUBSRIBE: break;
case tsip_event_subscribe_type_e.AO_SUBSCRIBE:
case tsip_event_subscribe_type_e.AO_UNSUBSCRIBE:
case tsip_event_subscribe_type_e.AO_NOTIFY:
{
s_type = 'i_ao_request';
break;
}
case tsip_event_subscribe_type_e.I_NOTIFY:
{
s_type = 'i_notify';
break;
}
}
if(s_type){
oSession.dispatchEvent({ s_type: s_type, o_value: new SIPml.Session.Event(oSession, s_type, e) });
}
}
// listen for INVITE events
this.o_stack.on_event_invite = function (e) {
var s_type = null;
var i_session_id = e.o_session.i_id;
var oSession = e.o_session.o_stack.oStack.ao_sessions[i_session_id];
if (!oSession) {
switch (e.e_invite_type) {
case tsip_event_invite_type_e.I_NEW_CALL:
case tsip_event_invite_type_e.M_STREAM_LOCAL_REQUESTED:
case tsip_event_invite_type_e.M_STREAM_LOCAL_ACCEPTED:
case tsip_event_invite_type_e.M_STREAM_LOCAL_REFUSED:
break;
case tsip_event_invite_type_e.M_STREAM_LOCAL_ADDED:
case tsip_event_invite_type_e.M_STREAM_REMOTE_ADDED:
case tsip_event_invite_type_e.M_STREAM_LOCAL_REMOVED:
case tsip_event_invite_type_e.M_STREAM_REMOTE_REMOVED:
case tsip_event_invite_type_e.I_AO_REQUEST:
tsk_utils_log_info('Not notifying to session with id = ' + i_session_id + ' for event = ' + e.e_invite_type);
return;
default:
tsk_utils_log_warn('Cannot find session with id = ' + i_session_id + ' and event = ' + e.e_invite_type);
return;
}
}
var _setStream = function(o_view, o_stream, o_url, b_audio){
if(o_stream){
if(!b_audio && o_stream.videoTracks.length > 0){
if (window.HTMLVideoElement && o_view instanceof window.HTMLVideoElement){
if((o_view.src = o_url)){
o_view.play();
}
}
return true;
}
if(b_audio && o_stream.audioTracks.length > 0){
if (window.HTMLAudioElement && o_view instanceof window.HTMLAudioElement){
if((o_view.src = o_url)){
o_view.play();
}
}
return true;
}
}
}
var attachStream = function(bLocal){
var o_stream = bLocal ? e.o_session.get_stream_local() : e.o_session.get_stream_remote();
var o_url = bLocal ? e.o_session.get_url_local() : e.o_session.get_url_remote();
if(_setStream((bLocal ? oSession.videoLocal : oSession.videoRemote), o_stream, o_url, false)){
dispatchEvent(bLocal ? 'm_stream_video_local_added' : 'm_stream_video_remote_added');
}
if(_setStream((bLocal ? oSession.audioLocal : oSession.audioRemote), o_stream, o_url, true)){
dispatchEvent(bLocal ? 'm_stream_audio_local_added' : 'm_stream_audio_remote_added');
}
}
var deattachStream = function(bLocal){
var o_stream = bLocal ? e.o_session.get_stream_local() : e.o_session.get_stream_remote();
if(_setStream((bLocal ? oSession.videoLocal : oSession.videoRemote), o_stream, null, false)){
dispatchEvent(bLocal ? 'm_stream_video_local_removed' : 'm_stream_video_remote_removed');
}
if(_setStream((bLocal ? oSession.audioLocal : oSession.audioRemote), o_stream, null, true)){
dispatchEvent(bLocal ? 'm_stream_audio_local_removed' : 'm_stream_audio_remote_removed');
}
}
var dispatchEvent = function (s_event_type) {
if (s_event_type) {
// 'i_new_call', 'm_permission_requested', 'm_permission_accepted' and 'm_permission_refused' are stack-level event
switch (s_event_type) {
case 'i_new_call':
case 'm_permission_requested':
case 'm_permission_accepted':
case 'm_permission_refused':
{
var oNewEvent = new SIPml.Stack.Event(s_event_type, e);
if(s_event_type == 'i_new_call'){
oNewEvent.newSession = new SIPml.Session.Call(e.o_session);
e.o_session.o_stack.oStack.ao_sessions[i_session_id] = oNewEvent.newSession; // save session
}
e.o_session.o_stack.oStack.dispatchEvent({ s_type: s_event_type, o_value: oNewEvent });
break;
}
default:
{
oSession.dispatchEvent({ s_type: s_event_type, o_value: new SIPml.Session.Event(oSession, s_event_type, e) });
break;
}
}
}
}
switch (e.e_invite_type) {
case tsip_event_invite_type_e.I_NEW_CALL: s_type = 'i_new_call'; break;
case tsip_event_invite_type_e.I_ECT_NEW_CALL: s_type = 'i_ect_new_call'; break;
case tsip_event_invite_type_e.I_AO_REQUEST: s_type = 'i_ao_request'; break;
case tsip_event_invite_type_e.M_EARLY_MEDIA: s_type = 'm_early_media'; break;
case tsip_event_invite_type_e.M_STREAM_LOCAL_REQUESTED: s_type = 'm_permission_requested'; break;
case tsip_event_invite_type_e.M_STREAM_LOCAL_ACCEPTED: s_type = 'm_permission_accepted'; break;
case tsip_event_invite_type_e.M_STREAM_LOCAL_REFUSED: s_type = 'm_permission_refused'; break;
case tsip_event_invite_type_e.M_STREAM_LOCAL_ADDED:
{
return attachStream(true);
}
case tsip_event_invite_type_e.M_STREAM_LOCAL_REMOVED:
{
return deattachStream(true);
}
case tsip_event_invite_type_e.M_STREAM_REMOTE_ADDED:
{
return attachStream(false);
}
case tsip_event_invite_type_e.M_STREAM_REMOTE_REMOVED:
{
return deattachStream(false);
}
case tsip_event_invite_type_e.M_LOCAL_HOLD_OK: s_type = 'm_local_hold_ok'; break;
case tsip_event_invite_type_e.M_LOCAL_HOLD_NOK: s_type = 'm_local_hold_nok'; break;
case tsip_event_invite_type_e.M_LOCAL_RESUME_OK: s_type = 'm_local_resume_ok'; break;
case tsip_event_invite_type_e.M_LOCAL_RESUME_NOK: s_type = 'm_local_resume_nok'; break;
case tsip_event_invite_type_e.M_REMOTE_HOLD: s_type = 'm_remote_hold'; break;
case tsip_event_invite_type_e.M_REMOTE_RESUME: s_type = 'm_remote_resume'; break;
case tsip_event_invite_type_e.O_ECT_TRYING: s_type = 'o_ect_trying'; break;
case tsip_event_invite_type_e.O_ECT_ACCEPTED: s_type = 'o_ect_accepted'; break;
case tsip_event_invite_type_e.O_ECT_COMPLETED: s_type = 'o_ect_completed'; break;
case tsip_event_invite_type_e.I_ECT_COMPLETED: s_type = 'i_ect_completed'; break;
case tsip_event_invite_type_e.O_ECT_FAILED: s_type = 'o_ect_failed'; break;
case tsip_event_invite_type_e.I_ECT_FAILED: s_type = 'i_ect_failed'; break;
case tsip_event_invite_type_e.O_ECT_NOTIFY: s_type = 'o_ect_notify'; break;
case tsip_event_invite_type_e.I_ECT_NOTIFY: s_type = 'i_ect_notify'; break;
case tsip_event_invite_type_e.I_ECT_REQUESTED: s_type = 'i_ect_requested'; break;
default: break;
}
// dispatch event
dispatchEvent(s_type);
}
}
SIPml.Stack.prototype = Object.create(SIPml.EventTarget.prototype);
SIPml.Stack.prototype.ao_sessions = [];
/**
Updates configuration values.
@param {SIPml.Stack.Configuration} configuration Configuration object value.
@returns {Integer} 0 if successful; otherwise nonzero
@example
// add two new headers and change the <i>proxy_url</i>
o_stack.setConfiguration({
proxy_url: 'ws://192.168.0.10:5060',
sip_headers: [
{name: 'User-Agent', value: 'IM-client/OMA1.0 sipML5-v1.0.89.0'},
{name: 'Organization', value: 'Doubango Telecom'}
]
}
);
*/
SIPml.Stack.prototype.setConfiguration = function (o_conf) {
if (o_conf.realm && !tsk_string_is_string(o_conf.realm)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.realm + "' not a valid type for realm. String is expected");
}
if (o_conf.impi && !tsk_string_is_string(o_conf.impi)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.impi + "' not a valid type for impi. String is expected");
}
if (o_conf.impu && !tsk_string_is_string(o_conf.impu)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.impu + "' not a valid type for impu. String is expected");
}
if (o_conf.password && !tsk_string_is_string(o_conf.password)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.password + "' not a valid type for password. String is expected");
}
if (o_conf.display_name && !tsk_string_is_string(o_conf.display_name)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.display_name + "' not a valid type for display_name. String is expected");
}
if (o_conf.websocket_proxy_url && !tsk_string_is_string(o_conf.websocket_proxy_url)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.websocket_proxy_url + "' not a valid type for websocket_proxy_url. String is expected");
}
if (o_conf.outbound_proxy_url && !tsk_string_is_string(o_conf.outbound_proxy_url)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.outbound_proxy_url + "' not a valid type for outbound_proxy_url. String is expected");
}
if (o_conf.sip_headers && typeof o_conf.sip_headers != "Array" && !(o_conf.sip_headers instanceof Array)) {
throw new Error("ERR_INVALID_PARAMETER_TYPE: '" + typeof o_conf.sip_headers + "' not a valid type for sip_headers. Array is expected");
}
// event-listener: must be first to be defined as other configs could raise events
if(o_conf.events_listener){
this.addEventListener(o_conf.events_listener.events, o_conf.events_listener.listener);
}
var b_rtcweb_breaker_enabled = !!o_conf.enable_rtcweb_breaker;
var o_stack = this.o_stack;
tsk_utils_log_info("s_websocket_server_url=" + (o_conf.websocket_proxy_url || "(null)"));
tsk_utils_log_info("s_sip_outboundproxy_url=" + (o_conf.outbound_proxy_url || "(null)"));
tsk_utils_log_info("b_rtcweb_breaker_enabled=" + (b_rtcweb_breaker_enabled ? "yes" : "no"));
o_stack.set(tsip_stack.prototype.SetPassword(o_conf.password),
tsip_stack.prototype.SetDisplayName(o_conf.display_name),
tsip_stack.prototype.SetProxyOutBoundUrl(o_conf.outbound_proxy_url),
tsip_stack.prototype.SetRTCWebBreakerEnabled(b_rtcweb_breaker_enabled),
tsip_stack.prototype.SetSecureTransportEnabled(b_rtcweb_breaker_enabled), // always use secure transport when RTCWebBreaker
tsip_stack.prototype.SetWebsocketServerUrl(o_conf.websocket_proxy_url));
// add sip headers
if (o_conf.sip_headers) {
o_conf.sip_headers.forEach(function (o_header) {
if (o_header && !tsk_string_is_null_or_empty(o_header.name) && (!o_header.value || tsk_string_is_string(o_header.value))) {
o_stack.set(
tsip_stack.prototype.SetHeader(o_header.name, o_header.value)
);
}
});
}
return 0;
}
/**
Starts the SIP stack and connect the network transport to the WebSocket server without sending any SIP request.
This function must be be called before any attempt to make or receive calls/messages. This function is asynchronous which means that the stack will not be immediately started after the call.
Please check <a href="SIPml.EventTarget.html#SIPml.EventTarget.Stack">this link</a> for more information on all supported events.