Skip to content

Commit

Permalink
update node js code snippet (generated client)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Aug 29, 2024
1 parent 54dc178 commit 369275f
Show file tree
Hide file tree
Showing 15 changed files with 966 additions and 158 deletions.
16 changes: 15 additions & 1 deletion docusaurus/video/docusaurus/docs/api/_common_/async-tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem';
const response = await client.<async operation>();

// you need to poll this endpoint
const taskResponse = await client.getTaskStatus({id: response.task_id})
const taskResponse = await client.getTask({id: response.task_id})

console.log(taskResponse.status === 'completed');
```
Expand Down Expand Up @@ -45,5 +45,19 @@ curl -X GET https://video.stream-io-api.com/api/v2/tasks/${TASK_ID}?api_key=${AP
-H "stream-auth-type: jwt"
```

</TabItem>
<TabItem value="js-deprecated" label="[email protected] (deprecated)">

```js
// Example of monitoring the status of an async task
// The logic is same for all async tasks
const response = await client.<async operation>();

// you need to poll this endpoint
const taskResponse = await client.getTaskStatus({id: response.task_id})

console.log(taskResponse.status === 'completed');
```

</TabItem>
</Tabs>
15 changes: 14 additions & 1 deletion docusaurus/video/docusaurus/docs/api/_common_/custom-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TabItem from '@theme/TabItem';

```js
// send a custom event to all users watching the call
call.sendCustomEvent({
call.sendCallEvent({
custom: {
'render-animation': 'balloons',
},
Expand Down Expand Up @@ -36,5 +36,18 @@ curl -X POST https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CA
}'
```

</TabItem>
<TabItem value="js-deprecated" label="[email protected] (deprecated)">

```js
// send a custom event to all users watching the call
call.sendCustomEvent({
custom: {
'render-animation': 'balloons',
},
user_id: 'john',
});
```

</TabItem>
</Tabs>
30 changes: 23 additions & 7 deletions docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ const resp = await call.get();

// userId of existing user
const userId = 'jane';
await client.upsertUsers({
users: {
[userId]: {
id: userId,
},
},
});
await client.upsertUsers([{ id: userId }]);
const token = client.createToken(userId);
const rtmpURL = resp.call.ingress.rtmp.address;
const streamKey = token;
Expand Down Expand Up @@ -57,5 +51,27 @@ curl -X GET "https://video.stream-io-api.com/api/v2/video/call/livestream/${CALL
# Stream key: create a user token
```

</TabItem>
<TabItem value="js-deprecated" label="[email protected] (deprecated)">

```js
const resp = await call.get();

// userId of existing user
const userId = 'jane';
await client.upsertUsers({
users: {
[userId]: {
id: userId,
},
},
});
const token = client.createToken(userId);
const rtmpURL = resp.call.ingress.rtmp.address;
const streamKey = token;

console.log(rtmpURL, streamKey);
```

</TabItem>
</Tabs>
Loading

0 comments on commit 369275f

Please sign in to comment.