vivox-sdk-node 1.0.0 → 1.1.1
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 +74 -44
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,62 +1,92 @@
|
|
|
1
|
-
# Vivox SDK Node.js
|
|
1
|
+
# Vivox SDK Node.js Wrapper
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A high-performance, fully type-safe Node.js C++ addon for the Vivox SDK. This wrapper provides an asynchronous, EventEmitter-based API to integrate Vivox voice and text chat into your Node.js applications.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
- **Çoklu Mimari Desteği:** `binding.gyp` dosyası x64, Win32 ve arm64 mimarileri için doğru kütüphane ve DLL eşleştirmelerini otomatik yapar.
|
|
7
|
-
- **Asenkron Olay Döngüsü:** C++ tarafında çalışan bir arka plan iş parçacığı (background thread), Vivox SDK'sından gelen mesajları toplar ve Node.js tarafına `ThreadSafeFunction` kullanarak iletir.
|
|
8
|
-
- **Yüksek Performans:** N-API (Node-Addon-API) kullanılarak geliştirilmiştir.
|
|
5
|
+
## Features
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
- **Asynchronous Event Loop:** Native C++ thread handles Vivox messages and dispatches them to Node.js via `ThreadSafeFunction`.
|
|
8
|
+
- **Full TypeScript Support:** Includes comprehensive interfaces for all events, status codes, and SDK enums.
|
|
9
|
+
- **Strict Error Handling:** Automatically resolves numerical status codes into official Vivox SDK error names (e.g., `VX_E_ACCESSTOKEN_ALREADY_USED`).
|
|
10
|
+
- **Memory Safe:** Implements proper lifecycle management for requests and internal SDK messages to prevent leaks.
|
|
11
|
+
- **Local Moderation:** Built-in methods for local muting, user volume control, and microphone muting.
|
|
12
|
+
- **Audio Injection:** Support for streaming mono 16-bit PCM WAV files into channels.
|
|
13
|
+
- **Positional Audio:** Simple 3D spatial audio positioning support.
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
- Node.js (v14 veya üzeri önerilir)
|
|
14
|
-
- Python 3.x
|
|
15
|
-
- Visual Studio 2017 veya üzeri (C++ Masaüstü Geliştirme iş yükü yüklü olmalıdır)
|
|
15
|
+
## Project Structure
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
1. `node-addon` dizinine gidin:
|
|
19
|
-
```bash
|
|
20
|
-
cd node-addon
|
|
21
|
-
```
|
|
22
|
-
2. Bağımlılıkları yükleyin:
|
|
23
|
-
```bash
|
|
24
|
-
npm install
|
|
25
|
-
```
|
|
26
|
-
3. Addon'u derleyin:
|
|
27
|
-
```bash
|
|
28
|
-
npm run build
|
|
29
|
-
```
|
|
17
|
+
The project has been optimized to be lightweight. The core SDK binaries and headers are stored locally within the package, making it portable and easy to install.
|
|
30
18
|
|
|
31
|
-
##
|
|
19
|
+
## Installation
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm install vivox-sdk-node
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
*Note: The native addon will automatically compile during installation if build tools (Python, Visual Studio/C++) are available.*
|
|
26
|
+
|
|
27
|
+
## Connection Flow
|
|
28
|
+
|
|
29
|
+
Vivox requires a specific sequence of operations. You **must** create a connector before attempting to login.
|
|
30
|
+
|
|
31
|
+
1. **Initialize:** Call `vivox.initialize()`.
|
|
32
|
+
2. **Setup Listeners:** Listen for `connectorCreated`, `loginSuccess`, and `joinSuccess`.
|
|
33
|
+
3. **Create Connector:** Call `vivox.connectorCreate(serverUrl)`.
|
|
34
|
+
4. **Login:** Inside the `connectorCreated` event, call `vivox.login()` or `vivox.loginAnonymous()`.
|
|
35
|
+
5. **Join:** Inside the `loginSuccess` event, call `vivox.joinChannel()`.
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
34
38
|
|
|
35
39
|
```javascript
|
|
36
|
-
const vivox = require('
|
|
40
|
+
const vivox = require('vivox-sdk-node');
|
|
41
|
+
const { VivoxUtils, VivoxError } = require('vivox-sdk-node');
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
vivox.on('loginSuccess', (event) => {
|
|
40
|
-
console.log('Başarıyla giriş yapıldı');
|
|
41
|
-
});
|
|
43
|
+
vivox.initialize();
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
// Step 1: Wait for connector
|
|
46
|
+
vivox.on('connectorCreated', (event) => {
|
|
47
|
+
if (event.status === VivoxError.VX_E_SUCCESS) {
|
|
48
|
+
// Step 2: Login
|
|
49
|
+
vivox.loginAnonymous("main_connector", accountUri, LOGIN_TOKEN);
|
|
50
|
+
}
|
|
45
51
|
});
|
|
46
52
|
|
|
47
|
-
vivox.on('
|
|
48
|
-
|
|
53
|
+
vivox.on('loginSuccess', (event) => {
|
|
54
|
+
// Step 3: Join Channel
|
|
55
|
+
vivox.joinChannel(accountUri, channelUri, CHANNEL_TOKEN);
|
|
49
56
|
});
|
|
50
57
|
|
|
51
|
-
//
|
|
52
|
-
vivox.
|
|
58
|
+
// Start the flow
|
|
59
|
+
vivox.connectorCreate("https://your-vivox-server.com/app", "main_connector");
|
|
60
|
+
```
|
|
53
61
|
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
## Local Moderation Examples
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
// Mute yourself (other players won't hear you)
|
|
66
|
+
vivox.muteLocalMic("main_connector", true);
|
|
67
|
+
|
|
68
|
+
// Mute a specific participant locally (for you only)
|
|
69
|
+
vivox.setParticipantMute(sessionHandle, "sip:target-user@domain", true);
|
|
70
|
+
|
|
71
|
+
// Adjust volume of a specific participant
|
|
72
|
+
vivox.setParticipantVolume(sessionHandle, "sip:target-user@domain", 50);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Audio Injection
|
|
76
|
+
|
|
77
|
+
Inject a `.wav` file (must be 16-bit PCM, Mono, matching channel sample rate):
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
vivox.injectAudio(accountHandle, "path/to/audio.wav");
|
|
56
81
|
```
|
|
57
82
|
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
83
|
+
## Scripts
|
|
84
|
+
|
|
85
|
+
- `npm run build`: Rebuild the native C++ addon.
|
|
86
|
+
- `npm run compile`: Recompile the TypeScript wrapper.
|
|
87
|
+
- `npm test`: Run the standard connection example.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
This project is licensed under the MIT License.
|
|
92
|
+
Vivox SDK is a trademark of Unity Technologies.
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vivox-sdk-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "High-performance, type-safe Node.js wrapper for the Vivox SDK.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"install": "node-gyp rebuild",
|
|
9
9
|
"build": "node-gyp rebuild",
|
|
10
|
-
"test": "node
|
|
10
|
+
"test": "node example.js",
|
|
11
11
|
"compile": "npx tsc"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|