Skip to content

Commit

Permalink
update node js code snippet (generated client) (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz authored Aug 30, 2024
2 parents 54dc178 + f43008d commit 2cc09df
Show file tree
Hide file tree
Showing 15 changed files with 999 additions and 170 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="JavaScript@0.3 (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="JavaScript@0.3 (deprecated)">

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

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

// userId of existing user
const userId = 'jane';
await client.upsertUsers({
users: {
[userId]: {
id: userId,
},
},
});
const token = client.createToken(userId);
await client.upsertUsers([{ id: userId }]);
const token = client.generateUserToken({ user_id: 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="JavaScript@0.3 (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 2cc09df

Please sign in to comment.