@4players/odin-nodejs 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/cppsrc/odinclient.cpp +5 -1
- package/odin.client.d.ts +22 -2
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/tests/audio-recording/index.js +2 -2
- package/tests/sending-audio/index.js +2 -2
package/README.md
CHANGED
|
@@ -35,7 +35,15 @@ Having two libs also allows us to optimize for each platform without having to w
|
|
|
35
35
|
|
|
36
36
|
## Prerequisites
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
This NodeJS SDK is based on the native ODIN SDK and is implemented via Native NodeJS bindings. This means that during
|
|
39
|
+
`npm install` this module will be compiled, which means you may need to have a compiler installed.
|
|
40
|
+
|
|
41
|
+
For some target systems, precompiled libraries are provided:
|
|
42
|
+
- macOS (x86_64 and arm64)
|
|
43
|
+
- Windows (x86_64)
|
|
44
|
+
- Linux (x86_64)
|
|
45
|
+
|
|
46
|
+
Otherwise you need to have a C++ compiler installed. On macOS, you can install XCode and the command line tools. On Linux you need
|
|
39
47
|
to have GCC installed. More information can be found here: [node-gyp](https://github.com/nodejs/node-gyp).
|
|
40
48
|
|
|
41
49
|
## Getting Started and compiling
|
package/cppsrc/odinclient.cpp
CHANGED
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
Napi::Object OdinClient::Init(Napi::Env env, Napi::Object exports) {
|
|
12
12
|
// This method is used to hook the accessor and method callbacks
|
|
13
13
|
Napi::Function func = DefineClass(env, "OdinClient", {
|
|
14
|
-
InstanceMethod<&OdinClient::GenerateAccessToken>("
|
|
14
|
+
InstanceMethod<&OdinClient::GenerateAccessToken>("generateToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
15
15
|
InstanceMethod<&OdinClient::CreateRoom>("createRoom", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
16
|
+
InstanceMethod<&OdinClient::CreateRoomWithAccessToken>("createRoomWithToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
17
|
+
|
|
18
|
+
// Deprecated functions
|
|
19
|
+
InstanceMethod<&OdinClient::GenerateAccessToken>("generateAccessToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
16
20
|
InstanceMethod<&OdinClient::CreateRoomWithAccessToken>("createRoomWithAccessToken", static_cast<napi_property_attributes>(napi_writable | napi_configurable))
|
|
17
21
|
});
|
|
18
22
|
|
package/odin.client.d.ts
CHANGED
|
@@ -13,13 +13,23 @@ export declare class OdinClient {
|
|
|
13
13
|
constructor(sampleRate?: number, channelCount?: number);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Generates
|
|
16
|
+
* Generates a token for the given access key, room and user ID. This token can be used to join the room.
|
|
17
|
+
* To be more consistent with other SDKs, this method is deprecated. Use generateToken instead.
|
|
17
18
|
* @param accessKey - The access key to use to generate the token. You can get a free access token in our developer center
|
|
18
19
|
* @param roomId - The ID of the room to generate the token for.
|
|
19
20
|
* @param userId - The ID of the user to generate the token for.
|
|
21
|
+
* @deprecated Use generateToken instead
|
|
20
22
|
*/
|
|
21
23
|
generateAccessToken(accessKey: string, roomId: string, userId: string): string;
|
|
22
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Generates a room token for the given access key, room and user ID. This token can be used to join the room.
|
|
27
|
+
* @param accessKey - The access key to use to generate the token. You can get a free access token in our developer center
|
|
28
|
+
* @param roomId - The ID of the room to generate the token for.
|
|
29
|
+
* @param userId - The ID of the user to generate the token for.
|
|
30
|
+
*/
|
|
31
|
+
generateToken(accessKey: string, roomId: string, userId: string): string;
|
|
32
|
+
|
|
23
33
|
/**
|
|
24
34
|
* Creates a new local room instance with the given ID and user ID. Use join to connect to that room.
|
|
25
35
|
* @param accessKey - The access key to use to generate the token. You can get a free access token in our developer center
|
|
@@ -31,8 +41,18 @@ export declare class OdinClient {
|
|
|
31
41
|
/**
|
|
32
42
|
* Creates a new local room instance with the given access token. Use `join` on the returned OdinRoom instance to
|
|
33
43
|
* connect to that room. Use this method if you already have an access token, either created elsewhere or by calling
|
|
34
|
-
* `
|
|
44
|
+
* `generateToken`.
|
|
45
|
+
* To be more consistent with other SDKs, this method is deprecated. Use createRoomWithToken instead.
|
|
35
46
|
* @param accessToken - The access token to use to join the room.
|
|
47
|
+
* @deprecated Use createRoomWithToken instead
|
|
36
48
|
*/
|
|
37
49
|
createRoomWithAccessToken(accessToken: string): OdinRoom;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new local room instance with the given room token. Use `join` on the returned OdinRoom instance to
|
|
53
|
+
* connect to that room. Use this method if you already have an access token, either created elsewhere or by calling
|
|
54
|
+
* `generateAccessToken`.
|
|
55
|
+
* @param accessToken - The access token to use to join the room.
|
|
56
|
+
*/
|
|
57
|
+
createRoomWithToken(accessToken: string): OdinRoom;
|
|
38
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4players/odin-nodejs",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "NodeJS bindings for the ODIN SDK. Use for AI enhanced human interactions, content moderation and audio processing features in a backend.",
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"types": "index.d.ts",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -18,8 +18,8 @@ const configuration = new Configuration({
|
|
|
18
18
|
const openai = new OpenAIApi(configuration);
|
|
19
19
|
|
|
20
20
|
// Create an odin client instance using our access key and create a room
|
|
21
|
-
const odinClient = new OdinClient(
|
|
22
|
-
const room = odinClient.createRoom(roomName, userName);
|
|
21
|
+
const odinClient = new OdinClient();
|
|
22
|
+
const room = odinClient.createRoom(accessKey, roomName, userName);
|
|
23
23
|
|
|
24
24
|
// Listen on PeerJoined messages and print the user data of the joined peer
|
|
25
25
|
room.addEventListener('PeerJoined', (event) => {
|
|
@@ -24,8 +24,8 @@ const data = new TextEncoder().encode(JSON.stringify(userData));
|
|
|
24
24
|
const odinClient = new OdinClient(48000, 2);
|
|
25
25
|
|
|
26
26
|
// Create a token then join the room with that token, token may also be created elsewhere
|
|
27
|
-
const token = odinClient.
|
|
28
|
-
const room = odinClient.
|
|
27
|
+
const token = odinClient.generateToken(accessKey, roomName, userName);
|
|
28
|
+
const room = odinClient.createRoomWithToken(token);
|
|
29
29
|
|
|
30
30
|
// It's also possible to create a room with an access key, room name and username then token is created internally
|
|
31
31
|
//const room = odinClient.createRoom(accessKey, roomName, userName);
|