-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add plain js session timers docs (#1420)
Adds an article about Session Timers to our plain JS docs. Also fixes a couple of issues in existing session timers docs: 1. Typo in call duration 2. Code formatting for RN article 3. Adds a section explaining overriding call settings from the client
- Loading branch information
1 parent
3ae4fe9
commit 938f02e
Showing
3 changed files
with
142 additions
and
112 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
packages/client/docusaurus/docs/javascript/10-advanced/11-session-timers.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
id: session-timers | ||
title: Session Timers | ||
--- | ||
|
||
A session timer allows you to limit the maximum duration of a call. The duration | ||
[can be configured](https://getstream.io/video/docs/api/calls/#session-timers) | ||
for all calls of a certain type, or on a per-call basis. When a session timer | ||
reaches zero, the call automatically ends. | ||
|
||
## Creating a call with a session timer | ||
|
||
Let's see how to create a single call with a limited duration: | ||
|
||
```ts | ||
const callType = 'default'; | ||
const callId = 'test-call'; | ||
|
||
const call = client.call(callType, callId); | ||
await call.getOrCreate({ | ||
data: { | ||
settings_override: { | ||
limits: { | ||
max_duration_seconds: 3600, | ||
}, | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
This code creates a call with a duration of 3600 seconds (1 hour) from the time | ||
the session is starts (a participant joins the call). | ||
|
||
After joining the call with the specified `max_duration_seconds`, you can | ||
examine a session's `timer_ends_at` field, which provides the timestamp when the | ||
call will end. When a call ends, all participants are removed from the call. | ||
|
||
```ts | ||
await call.join(); | ||
console.log(call.state.session?.timer_ends_at); | ||
``` | ||
|
||
## Extending a call | ||
|
||
You can also extend the duration of a call, both before or during the call. To | ||
do that, you should use the `call.update` method: | ||
|
||
```ts | ||
await call.get(); | ||
// extend by 1 minute | ||
const duration = call.state.settings?.limits.max_duration_seconds + 60; | ||
|
||
await call.update({ | ||
settings_override: { | ||
limits: { | ||
max_duration_seconds: duration, | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
If the call duration is extended, the `timer_ends_at` is updated to reflect this | ||
change. Call participants will receive the `call.updated` event to notify them | ||
about this change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters