@4players/odin-nodejs 0.7.3 → 0.7.4
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/index.d.ts +6 -0
- package/odin.client.d.ts +5 -5
- package/odin.media.d.ts +5 -4
- package/odin.room.d.ts +17 -13
- package/package.json +3 -2
- package/prebuilds/linux-x64/node.napi.node +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
Native Node JS bindings for the ODIN SDK. It is based on the [ODIN Native SDK](https://github.com/4Players/odin-sdk) and
|
|
4
4
|
wraps the C++ code into a Node JS module.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Check out documentation and guides at [developers.4players.io](https://www.4players.io/odin/sdk/nodejs).
|
|
7
|
+
|
|
8
|
+
## Beta!
|
|
9
|
+
|
|
10
|
+
**This SDK is currently in beta. This means that the API is not final and might change in the future. It's also not ready
|
|
11
|
+
for production use as there might be bugs, memory leaks or other issues.** But it's good enough for testing AI
|
|
12
|
+
integration, recording or other interesting use cases.
|
|
13
|
+
|
|
14
|
+
If you have any questions or feedback, please reach out to us at our [Discord Server](https://4np.de/discord).
|
|
7
15
|
|
|
8
16
|
## ODIN Node JS compared to Web SDK
|
|
9
17
|
|
package/index.d.ts
CHANGED
|
@@ -2,4 +2,10 @@ export * from "./odin.client";
|
|
|
2
2
|
export * from "./odin.room";
|
|
3
3
|
export * from "./odin.media";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Generates an access token for a room and user ID. You can use this to join a room with a custom access token.
|
|
7
|
+
* @param accessKey - The access key to use for this client. You can get one from https://developers.4players.io
|
|
8
|
+
* @param roomId - The ID of the room to create.
|
|
9
|
+
* @param userId - The ID of the user
|
|
10
|
+
*/
|
|
5
11
|
export declare function generateAccessToken(accessKey: string, roomId: string, userId: string): string;
|
package/odin.client.d.ts
CHANGED
|
@@ -7,16 +7,16 @@ import {OdinRoom} from "./odin.room";
|
|
|
7
7
|
export declare class OdinClient {
|
|
8
8
|
/**
|
|
9
9
|
* Creates a new instance of a client with an access key.
|
|
10
|
-
* @param accessKey
|
|
11
|
-
* @param sampleRate
|
|
12
|
-
* @param channelCount
|
|
10
|
+
* @param accessKey - The access key to use for this client. You can get one from https://developers.4players.io
|
|
11
|
+
* @param sampleRate - The sample rate of the audio stream (between 8000 and 48000)
|
|
12
|
+
* @param channelCount - The number of channels of the audio stream (1 or 2)
|
|
13
13
|
*/
|
|
14
14
|
constructor(accessKey: string, sampleRate?: number, channelCount?: number);
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Creates a new local room instance with the given ID and user ID. Use join to connect to that room.
|
|
18
|
-
* @param roomId
|
|
19
|
-
* @param userId
|
|
18
|
+
* @param roomId - The ID of the room to create.
|
|
19
|
+
* @param userId - The ID of the user to create the room for.
|
|
20
20
|
*/
|
|
21
21
|
createRoom(roomId: string, userId: string): OdinRoom;
|
|
22
22
|
}
|
package/odin.media.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ import {OdinRoom} from "./odin.room";
|
|
|
7
7
|
export declare class OdinMedia {
|
|
8
8
|
/**
|
|
9
9
|
* Creates a new instance of a media object. Don't create OdinMedia directly, use `createAudioStream` from OdinRoom instead.
|
|
10
|
-
* @param room
|
|
11
|
-
* @param sampleRate
|
|
12
|
-
* @param channelCount
|
|
10
|
+
* @param room - The room to add the media to.
|
|
11
|
+
* @param sampleRate - The sample rate of the audio stream (between 8000 and 48000)
|
|
12
|
+
* @param channelCount - The number of channels of the audio stream (1 or 2)
|
|
13
13
|
*/
|
|
14
14
|
constructor(room: OdinRoom, sampleRate: number, channelCount: number);
|
|
15
15
|
|
|
@@ -22,12 +22,13 @@ export declare class OdinMedia {
|
|
|
22
22
|
* Sends audio data to the room. The data must be in the format specified when creating the media as a 32-bit float array.
|
|
23
23
|
* Samples need to be between -1 and 1. Audio data needs to be sent in regular intervals, otherwise the audio will be sound
|
|
24
24
|
* interrupted. See the example for more details.
|
|
25
|
-
* @param data
|
|
25
|
+
* @param data - A 32-bit float array containing the audio data.
|
|
26
26
|
*/
|
|
27
27
|
sendAudioData(data: Float32Array): void;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Gets the ID of the media.
|
|
31
|
+
* @returns The ID of the media.
|
|
31
32
|
*/
|
|
32
33
|
get id(): string;
|
|
33
34
|
}
|
package/odin.room.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {OdinMedia} from "./odin.media";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Defines available Odin events
|
|
5
|
+
*/
|
|
3
6
|
declare interface OdinEvents {
|
|
4
7
|
/**
|
|
5
8
|
* Fired when the local user connected to the room (successfully joined).
|
|
@@ -399,52 +402,52 @@ export declare interface OdinAPMSettings {
|
|
|
399
402
|
export declare class OdinRoom {
|
|
400
403
|
/**
|
|
401
404
|
* Creates a new instance of a room with a token. Use OdinClient if you don't want to manage tokens yourself.
|
|
402
|
-
* @param token
|
|
405
|
+
* @param token - The token to use for this room.
|
|
403
406
|
*/
|
|
404
407
|
constructor(token: string);
|
|
405
408
|
|
|
406
409
|
/**
|
|
407
410
|
* Joins the room with the given gateway URL and optional user data.
|
|
408
|
-
* @param gatewayUrl
|
|
409
|
-
* @param userData
|
|
411
|
+
* @param gatewayUrl - The gateway URL to connect to. Use gateway.odin.4players.io if you are unsure.
|
|
412
|
+
* @param userData - The user data to send to the room. This can be used to identify the user.
|
|
410
413
|
*/
|
|
411
414
|
join(gatewayUrl: string, userData?: Uint8Array): void;
|
|
412
415
|
|
|
413
416
|
/**
|
|
414
417
|
* Sends a message to the room.
|
|
415
|
-
* @param message
|
|
416
|
-
* @param peerIdList
|
|
418
|
+
* @param message - The message to send as a byte array.
|
|
419
|
+
* @param peerIdList - The list of peer IDs to send the message to. If this is undefined, the message will be sent to all peers. If the list is defined and empty an error will be thrown.
|
|
417
420
|
*/
|
|
418
421
|
sendMessage(message: Uint8Array, peerIdList?: number[]): void;
|
|
419
422
|
|
|
420
423
|
/**
|
|
421
424
|
* Adds an event listener to the room for specific events.
|
|
422
|
-
* @param
|
|
423
|
-
* @param
|
|
425
|
+
* @param eventName - The event to listen for (see keys of OdinEvents for possible values)
|
|
426
|
+
* @param handler - The callback to call when the event is fired.
|
|
424
427
|
*/
|
|
425
428
|
addEventListener<Event extends keyof OdinEvents>(eventName: Event, handler: OdinEvents[Event]): void;
|
|
426
429
|
|
|
427
430
|
/**
|
|
428
431
|
* Removes an event listener from the room for specific events.
|
|
429
|
-
* @param
|
|
432
|
+
* @param eventName - The event to remove the listener from (see keys of OdinEvents for possible values)
|
|
430
433
|
*/
|
|
431
434
|
removeEventListener<Event extends keyof OdinEvents>(eventName: Event): void;
|
|
432
435
|
|
|
433
436
|
/**
|
|
434
437
|
* Sets a global event listener that received all events, this can be helpful for debugging. Please use addEventListener instead for production code.
|
|
435
|
-
* @param callback
|
|
438
|
+
* @param callback - The callback to call when the event is fired.
|
|
436
439
|
*/
|
|
437
440
|
setEventListener(callback: (data: OdinEventPayload) => void): void;
|
|
438
441
|
|
|
439
442
|
/**
|
|
440
443
|
* Updates the peer user data of the local peer
|
|
441
|
-
* @param userData
|
|
444
|
+
* @param userData - The new user data to set.
|
|
442
445
|
*/
|
|
443
446
|
updateOwnUserData(userData: Uint8Array): void;
|
|
444
447
|
|
|
445
448
|
/**
|
|
446
449
|
* Updates the room user data (for all peers)
|
|
447
|
-
* @param userData
|
|
450
|
+
* @param userData - The new user data to set.
|
|
448
451
|
*/
|
|
449
452
|
updateRoomUserData(userData: Uint8Array): void;
|
|
450
453
|
|
|
@@ -466,8 +469,9 @@ export declare class OdinRoom {
|
|
|
466
469
|
/**
|
|
467
470
|
* Creates a local audio stream and adds it to the room. An OdinMedia object will be returned that allows you to send
|
|
468
471
|
* audio data.
|
|
469
|
-
* @param sampleRate
|
|
470
|
-
* @param channels
|
|
472
|
+
* @param sampleRate - The sample rate of the audio stream. Can be between 8000 and 48000.
|
|
473
|
+
* @param channels - The number of channels of the audio stream. Can be 1 or 2.
|
|
474
|
+
* @returns The OdinMedia object that allows you to send audio data.
|
|
471
475
|
*/
|
|
472
476
|
createAudioStream(sampleRate: number, channels: number, apmSettings?: OdinAPMSettings): OdinMedia;
|
|
473
477
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4players/odin-nodejs",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"node-gyp": "^9.3.1",
|
|
35
|
-
"prebuildify": "^5.0.1"
|
|
35
|
+
"prebuildify": "^5.0.1",
|
|
36
|
+
"typedoc": "^0.23.28"
|
|
36
37
|
},
|
|
37
38
|
"engines": {
|
|
38
39
|
"node": ">=18"
|
|
Binary file
|