Skip to content

Commit 8980381

Browse files
some guides in api documentation
1 parent dbe3266 commit 8980381

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

docs/api.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ A working knowledge of the SIP protocol is a prerequisite for working with this
2020
- Connect the user agent
2121
- Register the user agent
2222
- Place an outbound call
23+
- Make a transfer call
2324

2425
```ts
2526
import {
@@ -32,7 +33,8 @@ import {
3233
Session,
3334
SessionState,
3435
UserAgent,
35-
UserAgentOptions
36+
UserAgentOptions,
37+
InvitationAcceptOptions
3638
} from "sip.js";
3739

3840
/*
@@ -81,6 +83,20 @@ userAgent.delegate = {
8183
break;
8284
}
8385
});
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)
84100
}
85101
};
86102

@@ -145,6 +161,26 @@ userAgent.start().then(() => {
145161
// INVITE did not send
146162
});
147163

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+
});
148184
});
149185
```
150186

0 commit comments

Comments
 (0)