File tree 1 file changed +37
-1
lines changed
1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ A working knowledge of the SIP protocol is a prerequisite for working with this
20
20
- Connect the user agent
21
21
- Register the user agent
22
22
- Place an outbound call
23
+ - Make a transfer call
23
24
24
25
``` ts
25
26
import {
@@ -32,7 +33,8 @@ import {
32
33
Session ,
33
34
SessionState ,
34
35
UserAgent ,
35
- UserAgentOptions
36
+ UserAgentOptions ,
37
+ InvitationAcceptOptions
36
38
} from " sip.js" ;
37
39
38
40
/*
@@ -81,6 +83,20 @@ userAgent.delegate = {
81
83
break ;
82
84
}
83
85
});
86
+
87
+ // Handle incoming INVITE request.
88
+ let constrainsDefault: MediaStreamConstraints = {
89
+ audio: true ,
90
+ video: false ,
91
+ }
92
+
93
+ const options: InvitationAcceptOptions = {
94
+ sessionDescriptionHandlerOptions: {
95
+ constraints: constrainsDefault ,
96
+ },
97
+ }
98
+
99
+ incomingSession .accept (options )
84
100
}
85
101
};
86
102
@@ -145,6 +161,26 @@ userAgent.start().then(() => {
145
161
// INVITE did not send
146
162
});
147
163
164
+ // Send an outgoing REFER request
165
+ const transferTarget = UserAgent .makeURI (" sip:transfer@example.com" );
166
+
167
+ if (! transferTarget ) {
168
+ throw new Error (" Failed to create transfer target URI." );
169
+ }
170
+
171
+ outgoingSession .refer (transferTarget , {
172
+ // Example of extra headers in REFER request
173
+ requestOptions: {
174
+ extraHeaders: [
175
+ ' X-Referred-By-Someone: Username'
176
+ ]
177
+ },
178
+ requestDelegate: {
179
+ onAccept(): void {
180
+ // ...
181
+ }
182
+ }
183
+ });
148
184
});
149
185
```
150
186
You can’t perform that action at this time.
0 commit comments