vivox-sdk-node 1.0.0
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/LICENSE.txt +7 -0
- package/README.md +62 -0
- package/README.txt +10 -0
- package/binding.gyp +57 -0
- package/index.d.ts +249 -0
- package/index.js +279 -0
- package/package.json +41 -0
- package/src/vivox_addon.cpp +443 -0
- package/vivox_sdk/include/Vxc.h +3319 -0
- package/vivox_sdk/include/VxcErrors.h +300 -0
- package/vivox_sdk/include/VxcEvents.h +2608 -0
- package/vivox_sdk/include/VxcExports.h +83 -0
- package/vivox_sdk/include/VxcRequests.h +5589 -0
- package/vivox_sdk/include/VxcResponses.h +2255 -0
- package/vivox_sdk/include/VxcTypes.h +627 -0
- package/vivox_sdk/include/vivox-config.h +19 -0
- package/vivox_sdk/lib/vivoxsdk.dll +0 -0
- package/vivox_sdk/lib/vivoxsdk.lib +0 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2019 Unity Technologies.
|
|
2
|
+
|
|
3
|
+
This software is subject to, and made available under, the Unity Terms of Service (see Unity Terms of Service). Your use of this software constitutes your acceptance of such terms.
|
|
4
|
+
|
|
5
|
+
Unless expressly provided otherwise, the software under this license is made available strictly on an "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the Terms of Service for details on these and other terms and conditions.”
|
|
6
|
+
|
|
7
|
+
See "Third Party Notices.md" for third-party licenses information.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Vivox SDK Node.js Addon
|
|
2
|
+
|
|
3
|
+
Bu proje, Vivox SDK'sını Node.js projelerinde kullanabilmek için hazırlanmış bir C++ Addon'dur. Tüm Windows mimarilerini (x64, Win32, arm64) destekleyecek şekilde yapılandırılmıştır.
|
|
4
|
+
|
|
5
|
+
## Özellikler
|
|
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.
|
|
9
|
+
|
|
10
|
+
## Kurulum ve Derleme
|
|
11
|
+
|
|
12
|
+
### Ön Gereksinimler
|
|
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)
|
|
16
|
+
|
|
17
|
+
### Adımlar
|
|
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
|
+
```
|
|
30
|
+
|
|
31
|
+
## Kullanım
|
|
32
|
+
|
|
33
|
+
Yeni sürüm `EventEmitter` yapısını destekler:
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
const vivox = require('./index');
|
|
37
|
+
|
|
38
|
+
// Olayları dinle
|
|
39
|
+
vivox.on('loginSuccess', (event) => {
|
|
40
|
+
console.log('Başarıyla giriş yapıldı');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
vivox.on('participantAdded', (event) => {
|
|
44
|
+
console.log('Yeni katılımcı:', event.participant_uri);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
vivox.on('message', (event) => {
|
|
48
|
+
console.log(`${event.participant_uri} dedi ki: ${event.message}`);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// SDK'yı başlat
|
|
52
|
+
vivox.initialize();
|
|
53
|
+
|
|
54
|
+
// Test verileriyle bağlan (Otomatik Connector -> Login -> Join süreci)
|
|
55
|
+
vivox.connectWithTestData(require('./test_data.json'));
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Gelişmiş Özellikler
|
|
59
|
+
- **Cihaz Listeleme:** `vivox.getCaptureDevices()` ve `vivox.getRenderDevices()` çağrıları sonrası `captureDevices` ve `renderDevices` olayları tetiklenir.
|
|
60
|
+
- **Mesaj Gönderme:** `vivox.sendMessage(sessHandle, "Mesaj içeriği")`
|
|
61
|
+
- **Katılımcı Kontrolü:** `vivox.setParticipantMute(sessHandle, uri, true)` ve `vivox.setParticipantVolume(sessHandle, uri, 50)`
|
|
62
|
+
- **3D Ses:** `vivox.set3DPosition(acctHandle, x, y, z, channelUri)`
|
package/README.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
The recommended first steps for developers using the Vivox SDKs can be found on the Unity documentation site under “Get started” in the Vivox Core documentation: https://docs.unity.com/en-us/vivox-core.
|
|
2
|
+
|
|
3
|
+
You can set up and manage Vivox through the Unity Cloud Dashboard.
|
|
4
|
+
|
|
5
|
+
On the dashboard you can:
|
|
6
|
+
* Create one or more application credentials for accessing Vivox services.
|
|
7
|
+
* Find and download Vivox SDKs for several different client platforms, game engines, sample code, and more.
|
|
8
|
+
* Links to documentation such as developer guides, SDK APIs, Vivox Access Tokens, and Server to Server API.
|
|
9
|
+
* Submit support tickets.
|
|
10
|
+
* Review and monitor activity dashboards for your live applications.
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "vivoxsdk",
|
|
5
|
+
"sources": [ "src/vivox_addon.cpp" ],
|
|
6
|
+
"include_dirs": [
|
|
7
|
+
"<!@(node -p \"require('node-addon-api').include\")",
|
|
8
|
+
"vivox_sdk/include"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": [
|
|
11
|
+
"<!(node -p \"require('node-addon-api').gyp\")"
|
|
12
|
+
],
|
|
13
|
+
"defines": [
|
|
14
|
+
"NAPI_DISABLE_CPP_EXCEPTIONS",
|
|
15
|
+
"BUILD_SHARED"
|
|
16
|
+
],
|
|
17
|
+
"conditions": [
|
|
18
|
+
['OS=="win"', {
|
|
19
|
+
"msvs_settings": {
|
|
20
|
+
"VCCLCompilerTool": {
|
|
21
|
+
"ExceptionHandling": 1
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"conditions": [
|
|
25
|
+
['target_arch=="x64"', {
|
|
26
|
+
"libraries": [ "<(module_root_dir)/vivox_sdk/lib/vivoxsdk.lib" ],
|
|
27
|
+
"copies": [
|
|
28
|
+
{
|
|
29
|
+
"destination": "<(PRODUCT_DIR)",
|
|
30
|
+
"files": [ "<(module_root_dir)/vivox_sdk/lib/vivoxsdk.dll" ]
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}],
|
|
34
|
+
['target_arch=="ia32"', {
|
|
35
|
+
"libraries": [ "<(module_root_dir)/../SDK/Libraries/Release/Win32/vivoxsdk.lib" ],
|
|
36
|
+
"copies": [
|
|
37
|
+
{
|
|
38
|
+
"destination": "<(PRODUCT_DIR)",
|
|
39
|
+
"files": [ "<(module_root_dir)/../SDK/Libraries/Release/Win32/vivoxsdk.dll" ]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}],
|
|
43
|
+
['target_arch=="arm64"', {
|
|
44
|
+
"libraries": [ "<(module_root_dir)/../SDK/Libraries/Release/arm64/vivoxsdk.lib" ],
|
|
45
|
+
"copies": [
|
|
46
|
+
{
|
|
47
|
+
"destination": "<(PRODUCT_DIR)",
|
|
48
|
+
"files": [ "<(module_root_dir)/../SDK/Libraries/Release/arm64/vivoxsdk.dll" ]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}]
|
|
52
|
+
]
|
|
53
|
+
}]
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
/**
|
|
3
|
+
* Vivox SDK Hata Kodları
|
|
4
|
+
*/
|
|
5
|
+
export declare enum VivoxError {
|
|
6
|
+
VX_E_SUCCESS = 0,
|
|
7
|
+
VX_E_NO_MESSAGE_AVAILABLE = -1,
|
|
8
|
+
VX_E_INVALID_XML = 1000,
|
|
9
|
+
VX_E_NO_EXIST = 1001,
|
|
10
|
+
VX_E_MAX_CONNECTOR_LIMIT_EXCEEDED = 1002,
|
|
11
|
+
VX_E_MAX_SESSION_LIMIT_EXCEEDED = 1003,
|
|
12
|
+
VX_E_FAILED = 1004,
|
|
13
|
+
VX_E_ALREADY_LOGGED_IN = 1005,
|
|
14
|
+
VX_E_INVALID_ARGUMENT = 1008,
|
|
15
|
+
VX_E_INVALID_USERNAME_OR_PASSWORD = 1009,
|
|
16
|
+
VX_E_INSUFFICIENT_PRIVILEGE = 1010,
|
|
17
|
+
VX_E_NO_SUCH_SESSION = 1011,
|
|
18
|
+
VX_E_NOT_INITIALIZED = 1012,
|
|
19
|
+
VX_E_LOGIN_FAILED = 1014,
|
|
20
|
+
VX_E_WRONG_CONNECTOR = 1016,
|
|
21
|
+
VX_E_RTP_TIMEOUT = 1058,
|
|
22
|
+
VX_E_INVALID_AUTH_TOKEN = 1082,
|
|
23
|
+
VX_E_ACCESSTOKEN_ALREADY_USED = 20120,
|
|
24
|
+
VX_E_ACCESSTOKEN_EXPIRED = 20121,
|
|
25
|
+
VX_E_ACCESSTOKEN_INVALID_SIGNATURE = 20122,
|
|
26
|
+
VX_E_ACCESSTOKEN_CLAIMS_MISMATCH = 20123,
|
|
27
|
+
VX_E_ACCESSTOKEN_MALFORMED = 20124,
|
|
28
|
+
VxErrorSuccess = 0,
|
|
29
|
+
VxErrorFailed = 1004,
|
|
30
|
+
VxErrorInvalidArgument = 1008,
|
|
31
|
+
VxErrorNotLoggedIn = 5025,
|
|
32
|
+
VxErrorTargetObjectDoesNotExist = 1001,
|
|
33
|
+
VxErrorNotInitialized = 1012,
|
|
34
|
+
VxErrorAlreadyInitialized = 1085
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Giriş (Login) durumları
|
|
38
|
+
*/
|
|
39
|
+
export declare enum VivoxLoginState {
|
|
40
|
+
LoggedOut = 0,
|
|
41
|
+
LoggedIn = 1,
|
|
42
|
+
LoggingIn = 2,
|
|
43
|
+
LoggingOut = 3,
|
|
44
|
+
Resetting = 4,
|
|
45
|
+
Error = 100
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Ağ bağlantı durumları
|
|
49
|
+
*/
|
|
50
|
+
export declare enum VivoxConnectionState {
|
|
51
|
+
Disconnected = 0,
|
|
52
|
+
Connected = 1,
|
|
53
|
+
Recovering = 3,
|
|
54
|
+
FailedToRecover = 4,
|
|
55
|
+
Recovered = 5
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Katılımcının kanaldan ayrılma nedenleri
|
|
59
|
+
*/
|
|
60
|
+
export declare enum VivoxParticipantRemovedReason {
|
|
61
|
+
Left = 0,
|
|
62
|
+
Timeout = 1,
|
|
63
|
+
Kicked = 2,
|
|
64
|
+
Banned = 3
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Kanal medya (ses) durumları
|
|
68
|
+
*/
|
|
69
|
+
export declare enum VivoxSessionMediaState {
|
|
70
|
+
Disconnected = 1,
|
|
71
|
+
Connected = 2,
|
|
72
|
+
Ringing = 3,
|
|
73
|
+
Connecting = 6,
|
|
74
|
+
Disconnecting = 7
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Kanal metin (text) durumları
|
|
78
|
+
*/
|
|
79
|
+
export declare enum VivoxSessionTextState {
|
|
80
|
+
Disconnected = 0,
|
|
81
|
+
Connected = 1,
|
|
82
|
+
Connecting = 2,
|
|
83
|
+
Disconnecting = 3
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* SDK Mesaj Tipleri
|
|
87
|
+
*/
|
|
88
|
+
export declare enum VivoxMessageType {
|
|
89
|
+
None = 0,
|
|
90
|
+
Request = 1,
|
|
91
|
+
Response = 2,
|
|
92
|
+
Event = 3
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* SDK Log Seviyeleri
|
|
96
|
+
*/
|
|
97
|
+
export declare enum VivoxLogLevel {
|
|
98
|
+
None = -1,
|
|
99
|
+
Error = 0,
|
|
100
|
+
Warning = 1,
|
|
101
|
+
Info = 2,
|
|
102
|
+
Debug = 3,
|
|
103
|
+
Trace = 4,
|
|
104
|
+
All = 5
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Vivox SDK'nın desteklediği temel bir cihaz yapısı.
|
|
108
|
+
*/
|
|
109
|
+
export interface VivoxDevice {
|
|
110
|
+
name: string;
|
|
111
|
+
id: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* C++ tarafından gelen ham olay (raw event) formatı.
|
|
115
|
+
*/
|
|
116
|
+
export interface VivoxRawEvent {
|
|
117
|
+
type: VivoxMessageType;
|
|
118
|
+
resp_type?: number;
|
|
119
|
+
evt_type?: number;
|
|
120
|
+
status?: number;
|
|
121
|
+
status_string?: string;
|
|
122
|
+
participant_uri?: string;
|
|
123
|
+
message?: string;
|
|
124
|
+
session_handle?: string;
|
|
125
|
+
state?: number;
|
|
126
|
+
account_handle?: string;
|
|
127
|
+
is_current_user?: number;
|
|
128
|
+
reason?: number;
|
|
129
|
+
is_speaking?: number;
|
|
130
|
+
energy?: number;
|
|
131
|
+
connection_state?: number;
|
|
132
|
+
devices?: VivoxDevice[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Giriş (Login) durumundaki değişiklikleri belirten olay.
|
|
136
|
+
*/
|
|
137
|
+
export interface VivoxLoginStateEvent {
|
|
138
|
+
state: VivoxLoginState;
|
|
139
|
+
handle: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Kanala yeni bir katılımcının girdiğini belirten olay.
|
|
143
|
+
*/
|
|
144
|
+
export interface VivoxParticipantAddedEvent {
|
|
145
|
+
participant_uri: string;
|
|
146
|
+
is_current_user: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Kanaldan bir katılımcının ayrıldığını belirten olay.
|
|
150
|
+
*/
|
|
151
|
+
export interface VivoxParticipantRemovedEvent {
|
|
152
|
+
participant_uri: string;
|
|
153
|
+
reason: VivoxParticipantRemovedReason;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Bir katılımcının anlık konuşma (ses) aktivitesini belirten olay.
|
|
157
|
+
*/
|
|
158
|
+
export interface VivoxParticipantUpdatedEvent {
|
|
159
|
+
participant_uri: string;
|
|
160
|
+
is_speaking: boolean;
|
|
161
|
+
energy: number;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Kanal içindeki bir yazılı mesaj olayını belirtir.
|
|
165
|
+
*/
|
|
166
|
+
export interface VivoxMessageEvent {
|
|
167
|
+
participant_uri: string;
|
|
168
|
+
message: string;
|
|
169
|
+
session_handle: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Standart bir SDK yanıt olayını belirtir.
|
|
173
|
+
*/
|
|
174
|
+
export interface VivoxResponseEvent {
|
|
175
|
+
status: number;
|
|
176
|
+
status_name: string;
|
|
177
|
+
status_string?: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Vivox sınıfı tarafından fırlatılan tüm olayların tür haritası.
|
|
181
|
+
*/
|
|
182
|
+
export interface VivoxEvents {
|
|
183
|
+
'raw': (event: VivoxRawEvent) => void;
|
|
184
|
+
'response': (event: VivoxRawEvent) => void;
|
|
185
|
+
'event': (event: VivoxRawEvent) => void;
|
|
186
|
+
'connectorCreated': (event: VivoxResponseEvent) => void;
|
|
187
|
+
'loginSuccess': (event: VivoxResponseEvent) => void;
|
|
188
|
+
'loginFailure': (event: VivoxResponseEvent) => void;
|
|
189
|
+
'joinSuccess': (event: VivoxResponseEvent) => void;
|
|
190
|
+
'joinFailure': (event: VivoxResponseEvent) => void;
|
|
191
|
+
'renderDevices': (devices: VivoxDevice[]) => void;
|
|
192
|
+
'captureDevices': (devices: VivoxDevice[]) => void;
|
|
193
|
+
'loginStateChange': (data: VivoxLoginStateEvent) => void;
|
|
194
|
+
'participantAdded': (event: VivoxParticipantAddedEvent) => void;
|
|
195
|
+
'participantRemoved': (event: VivoxParticipantRemovedEvent) => void;
|
|
196
|
+
'participantUpdated': (event: VivoxParticipantUpdatedEvent) => void;
|
|
197
|
+
'connectionStateChanged': (state: VivoxConnectionState) => void;
|
|
198
|
+
'message': (event: VivoxMessageEvent) => void;
|
|
199
|
+
}
|
|
200
|
+
export declare interface Vivox {
|
|
201
|
+
on<U extends keyof VivoxEvents>(event: U, listener: VivoxEvents[U]): this;
|
|
202
|
+
emit<U extends keyof VivoxEvents>(event: U, ...args: Parameters<VivoxEvents[U]>): boolean;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Vivox SDK Node.js Wrapper
|
|
206
|
+
*/
|
|
207
|
+
export declare class Vivox extends EventEmitter {
|
|
208
|
+
private addon;
|
|
209
|
+
private initialized;
|
|
210
|
+
constructor();
|
|
211
|
+
getVersion(): string;
|
|
212
|
+
initialize(): number;
|
|
213
|
+
private _setupInternalCallback;
|
|
214
|
+
private _handleResponse;
|
|
215
|
+
private _handleEvent;
|
|
216
|
+
connectorCreate(server: string, handle?: string): number;
|
|
217
|
+
login(connectorHandle: string, accountUri: string, token: string): number;
|
|
218
|
+
loginAnonymous(connectorHandle: string, accountUri: string, token: string): number;
|
|
219
|
+
joinChannel(accountHandle: string, channelUri: string, token: string): number;
|
|
220
|
+
sendMessage(sessionHandle: string, message: string): number;
|
|
221
|
+
getCaptureDevices(): number;
|
|
222
|
+
setCaptureDevice(deviceId: string): number;
|
|
223
|
+
getRenderDevices(): number;
|
|
224
|
+
setRenderDevice(deviceId: string): number;
|
|
225
|
+
setLocalMicVolume(volume: number): number;
|
|
226
|
+
setLocalSpeakerVolume(volume: number): number;
|
|
227
|
+
muteLocalMic(connectorHandle: string, mute: boolean): number;
|
|
228
|
+
setParticipantMute(sessionHandle: string, participantUri: string, mute: boolean): number;
|
|
229
|
+
setParticipantVolume(sessionHandle: string, participantUri: string, volume: number): number;
|
|
230
|
+
muteUser(accountHandle: string, channelUri: string, participantUri: string, mute: boolean): number;
|
|
231
|
+
kickUser(accountHandle: string, channelUri: string, participantUri: string): number;
|
|
232
|
+
injectAudio(accountHandle: string, filename: string): number;
|
|
233
|
+
stopAudioInjection(accountHandle: string): number;
|
|
234
|
+
set3DPosition(accountHandle: string, posX: number, posY: number, posZ: number, channelUri: string): number;
|
|
235
|
+
uninitialize(): void;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Vivox Utility Fonksiyonları
|
|
239
|
+
*/
|
|
240
|
+
export declare const VivoxUtils: {
|
|
241
|
+
getErrorName(statusCode: number): string;
|
|
242
|
+
getLoginStateName(state: number): string;
|
|
243
|
+
getConnectionStateName(state: number): string;
|
|
244
|
+
generateAccountUri(domain: string, userId: string, environmentDomain: string): string;
|
|
245
|
+
generateChannelUri(domain: string, channelId: string, environmentDomain: string): string;
|
|
246
|
+
generateSessionHandle(channelUri: string): string;
|
|
247
|
+
};
|
|
248
|
+
declare const defaultInstance: Vivox;
|
|
249
|
+
export default defaultInstance;
|
package/index.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VivoxUtils = exports.Vivox = exports.VivoxLogLevel = exports.VivoxMessageType = exports.VivoxSessionTextState = exports.VivoxSessionMediaState = exports.VivoxParticipantRemovedReason = exports.VivoxConnectionState = exports.VivoxLoginState = exports.VivoxError = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
// C++ Eklentisini yüklüyoruz
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
|
+
const vivoxsdk = require('./build/Release/vivoxsdk.node');
|
|
8
|
+
/**
|
|
9
|
+
* Vivox SDK Hata Kodları
|
|
10
|
+
*/
|
|
11
|
+
var VivoxError;
|
|
12
|
+
(function (VivoxError) {
|
|
13
|
+
VivoxError[VivoxError["VX_E_SUCCESS"] = 0] = "VX_E_SUCCESS";
|
|
14
|
+
VivoxError[VivoxError["VX_E_NO_MESSAGE_AVAILABLE"] = -1] = "VX_E_NO_MESSAGE_AVAILABLE";
|
|
15
|
+
VivoxError[VivoxError["VX_E_INVALID_XML"] = 1000] = "VX_E_INVALID_XML";
|
|
16
|
+
VivoxError[VivoxError["VX_E_NO_EXIST"] = 1001] = "VX_E_NO_EXIST";
|
|
17
|
+
VivoxError[VivoxError["VX_E_MAX_CONNECTOR_LIMIT_EXCEEDED"] = 1002] = "VX_E_MAX_CONNECTOR_LIMIT_EXCEEDED";
|
|
18
|
+
VivoxError[VivoxError["VX_E_MAX_SESSION_LIMIT_EXCEEDED"] = 1003] = "VX_E_MAX_SESSION_LIMIT_EXCEEDED";
|
|
19
|
+
VivoxError[VivoxError["VX_E_FAILED"] = 1004] = "VX_E_FAILED";
|
|
20
|
+
VivoxError[VivoxError["VX_E_ALREADY_LOGGED_IN"] = 1005] = "VX_E_ALREADY_LOGGED_IN";
|
|
21
|
+
VivoxError[VivoxError["VX_E_INVALID_ARGUMENT"] = 1008] = "VX_E_INVALID_ARGUMENT";
|
|
22
|
+
VivoxError[VivoxError["VX_E_INVALID_USERNAME_OR_PASSWORD"] = 1009] = "VX_E_INVALID_USERNAME_OR_PASSWORD";
|
|
23
|
+
VivoxError[VivoxError["VX_E_INSUFFICIENT_PRIVILEGE"] = 1010] = "VX_E_INSUFFICIENT_PRIVILEGE";
|
|
24
|
+
VivoxError[VivoxError["VX_E_NO_SUCH_SESSION"] = 1011] = "VX_E_NO_SUCH_SESSION";
|
|
25
|
+
VivoxError[VivoxError["VX_E_NOT_INITIALIZED"] = 1012] = "VX_E_NOT_INITIALIZED";
|
|
26
|
+
VivoxError[VivoxError["VX_E_LOGIN_FAILED"] = 1014] = "VX_E_LOGIN_FAILED";
|
|
27
|
+
VivoxError[VivoxError["VX_E_WRONG_CONNECTOR"] = 1016] = "VX_E_WRONG_CONNECTOR";
|
|
28
|
+
VivoxError[VivoxError["VX_E_RTP_TIMEOUT"] = 1058] = "VX_E_RTP_TIMEOUT";
|
|
29
|
+
VivoxError[VivoxError["VX_E_INVALID_AUTH_TOKEN"] = 1082] = "VX_E_INVALID_AUTH_TOKEN";
|
|
30
|
+
VivoxError[VivoxError["VX_E_ACCESSTOKEN_ALREADY_USED"] = 20120] = "VX_E_ACCESSTOKEN_ALREADY_USED";
|
|
31
|
+
VivoxError[VivoxError["VX_E_ACCESSTOKEN_EXPIRED"] = 20121] = "VX_E_ACCESSTOKEN_EXPIRED";
|
|
32
|
+
VivoxError[VivoxError["VX_E_ACCESSTOKEN_INVALID_SIGNATURE"] = 20122] = "VX_E_ACCESSTOKEN_INVALID_SIGNATURE";
|
|
33
|
+
VivoxError[VivoxError["VX_E_ACCESSTOKEN_CLAIMS_MISMATCH"] = 20123] = "VX_E_ACCESSTOKEN_CLAIMS_MISMATCH";
|
|
34
|
+
VivoxError[VivoxError["VX_E_ACCESSTOKEN_MALFORMED"] = 20124] = "VX_E_ACCESSTOKEN_MALFORMED";
|
|
35
|
+
// V5 Aliasları
|
|
36
|
+
VivoxError[VivoxError["VxErrorSuccess"] = 0] = "VxErrorSuccess";
|
|
37
|
+
VivoxError[VivoxError["VxErrorFailed"] = 1004] = "VxErrorFailed";
|
|
38
|
+
VivoxError[VivoxError["VxErrorInvalidArgument"] = 1008] = "VxErrorInvalidArgument";
|
|
39
|
+
VivoxError[VivoxError["VxErrorNotLoggedIn"] = 5025] = "VxErrorNotLoggedIn";
|
|
40
|
+
VivoxError[VivoxError["VxErrorTargetObjectDoesNotExist"] = 1001] = "VxErrorTargetObjectDoesNotExist";
|
|
41
|
+
VivoxError[VivoxError["VxErrorNotInitialized"] = 1012] = "VxErrorNotInitialized";
|
|
42
|
+
VivoxError[VivoxError["VxErrorAlreadyInitialized"] = 1085] = "VxErrorAlreadyInitialized";
|
|
43
|
+
})(VivoxError || (exports.VivoxError = VivoxError = {}));
|
|
44
|
+
/**
|
|
45
|
+
* Giriş (Login) durumları
|
|
46
|
+
*/
|
|
47
|
+
var VivoxLoginState;
|
|
48
|
+
(function (VivoxLoginState) {
|
|
49
|
+
VivoxLoginState[VivoxLoginState["LoggedOut"] = 0] = "LoggedOut";
|
|
50
|
+
VivoxLoginState[VivoxLoginState["LoggedIn"] = 1] = "LoggedIn";
|
|
51
|
+
VivoxLoginState[VivoxLoginState["LoggingIn"] = 2] = "LoggingIn";
|
|
52
|
+
VivoxLoginState[VivoxLoginState["LoggingOut"] = 3] = "LoggingOut";
|
|
53
|
+
VivoxLoginState[VivoxLoginState["Resetting"] = 4] = "Resetting";
|
|
54
|
+
VivoxLoginState[VivoxLoginState["Error"] = 100] = "Error";
|
|
55
|
+
})(VivoxLoginState || (exports.VivoxLoginState = VivoxLoginState = {}));
|
|
56
|
+
/**
|
|
57
|
+
* Ağ bağlantı durumları
|
|
58
|
+
*/
|
|
59
|
+
var VivoxConnectionState;
|
|
60
|
+
(function (VivoxConnectionState) {
|
|
61
|
+
VivoxConnectionState[VivoxConnectionState["Disconnected"] = 0] = "Disconnected";
|
|
62
|
+
VivoxConnectionState[VivoxConnectionState["Connected"] = 1] = "Connected";
|
|
63
|
+
VivoxConnectionState[VivoxConnectionState["Recovering"] = 3] = "Recovering";
|
|
64
|
+
VivoxConnectionState[VivoxConnectionState["FailedToRecover"] = 4] = "FailedToRecover";
|
|
65
|
+
VivoxConnectionState[VivoxConnectionState["Recovered"] = 5] = "Recovered";
|
|
66
|
+
})(VivoxConnectionState || (exports.VivoxConnectionState = VivoxConnectionState = {}));
|
|
67
|
+
/**
|
|
68
|
+
* Katılımcının kanaldan ayrılma nedenleri
|
|
69
|
+
*/
|
|
70
|
+
var VivoxParticipantRemovedReason;
|
|
71
|
+
(function (VivoxParticipantRemovedReason) {
|
|
72
|
+
VivoxParticipantRemovedReason[VivoxParticipantRemovedReason["Left"] = 0] = "Left";
|
|
73
|
+
VivoxParticipantRemovedReason[VivoxParticipantRemovedReason["Timeout"] = 1] = "Timeout";
|
|
74
|
+
VivoxParticipantRemovedReason[VivoxParticipantRemovedReason["Kicked"] = 2] = "Kicked";
|
|
75
|
+
VivoxParticipantRemovedReason[VivoxParticipantRemovedReason["Banned"] = 3] = "Banned";
|
|
76
|
+
})(VivoxParticipantRemovedReason || (exports.VivoxParticipantRemovedReason = VivoxParticipantRemovedReason = {}));
|
|
77
|
+
/**
|
|
78
|
+
* Kanal medya (ses) durumları
|
|
79
|
+
*/
|
|
80
|
+
var VivoxSessionMediaState;
|
|
81
|
+
(function (VivoxSessionMediaState) {
|
|
82
|
+
VivoxSessionMediaState[VivoxSessionMediaState["Disconnected"] = 1] = "Disconnected";
|
|
83
|
+
VivoxSessionMediaState[VivoxSessionMediaState["Connected"] = 2] = "Connected";
|
|
84
|
+
VivoxSessionMediaState[VivoxSessionMediaState["Ringing"] = 3] = "Ringing";
|
|
85
|
+
VivoxSessionMediaState[VivoxSessionMediaState["Connecting"] = 6] = "Connecting";
|
|
86
|
+
VivoxSessionMediaState[VivoxSessionMediaState["Disconnecting"] = 7] = "Disconnecting";
|
|
87
|
+
})(VivoxSessionMediaState || (exports.VivoxSessionMediaState = VivoxSessionMediaState = {}));
|
|
88
|
+
/**
|
|
89
|
+
* Kanal metin (text) durumları
|
|
90
|
+
*/
|
|
91
|
+
var VivoxSessionTextState;
|
|
92
|
+
(function (VivoxSessionTextState) {
|
|
93
|
+
VivoxSessionTextState[VivoxSessionTextState["Disconnected"] = 0] = "Disconnected";
|
|
94
|
+
VivoxSessionTextState[VivoxSessionTextState["Connected"] = 1] = "Connected";
|
|
95
|
+
VivoxSessionTextState[VivoxSessionTextState["Connecting"] = 2] = "Connecting";
|
|
96
|
+
VivoxSessionTextState[VivoxSessionTextState["Disconnecting"] = 3] = "Disconnecting";
|
|
97
|
+
})(VivoxSessionTextState || (exports.VivoxSessionTextState = VivoxSessionTextState = {}));
|
|
98
|
+
/**
|
|
99
|
+
* SDK Mesaj Tipleri
|
|
100
|
+
*/
|
|
101
|
+
var VivoxMessageType;
|
|
102
|
+
(function (VivoxMessageType) {
|
|
103
|
+
VivoxMessageType[VivoxMessageType["None"] = 0] = "None";
|
|
104
|
+
VivoxMessageType[VivoxMessageType["Request"] = 1] = "Request";
|
|
105
|
+
VivoxMessageType[VivoxMessageType["Response"] = 2] = "Response";
|
|
106
|
+
VivoxMessageType[VivoxMessageType["Event"] = 3] = "Event";
|
|
107
|
+
})(VivoxMessageType || (exports.VivoxMessageType = VivoxMessageType = {}));
|
|
108
|
+
/**
|
|
109
|
+
* SDK Log Seviyeleri
|
|
110
|
+
*/
|
|
111
|
+
var VivoxLogLevel;
|
|
112
|
+
(function (VivoxLogLevel) {
|
|
113
|
+
VivoxLogLevel[VivoxLogLevel["None"] = -1] = "None";
|
|
114
|
+
VivoxLogLevel[VivoxLogLevel["Error"] = 0] = "Error";
|
|
115
|
+
VivoxLogLevel[VivoxLogLevel["Warning"] = 1] = "Warning";
|
|
116
|
+
VivoxLogLevel[VivoxLogLevel["Info"] = 2] = "Info";
|
|
117
|
+
VivoxLogLevel[VivoxLogLevel["Debug"] = 3] = "Debug";
|
|
118
|
+
VivoxLogLevel[VivoxLogLevel["Trace"] = 4] = "Trace";
|
|
119
|
+
VivoxLogLevel[VivoxLogLevel["All"] = 5] = "All";
|
|
120
|
+
})(VivoxLogLevel || (exports.VivoxLogLevel = VivoxLogLevel = {}));
|
|
121
|
+
/**
|
|
122
|
+
* Vivox SDK Node.js Wrapper
|
|
123
|
+
*/
|
|
124
|
+
class Vivox extends events_1.EventEmitter {
|
|
125
|
+
constructor() {
|
|
126
|
+
super();
|
|
127
|
+
this.addon = vivoxsdk;
|
|
128
|
+
this.initialized = false;
|
|
129
|
+
}
|
|
130
|
+
getVersion() {
|
|
131
|
+
return this.addon.getVersion();
|
|
132
|
+
}
|
|
133
|
+
initialize() {
|
|
134
|
+
const status = this.addon.initialize();
|
|
135
|
+
if (status === 0 && !this.initialized) {
|
|
136
|
+
this.initialized = true;
|
|
137
|
+
this._setupInternalCallback();
|
|
138
|
+
}
|
|
139
|
+
return status;
|
|
140
|
+
}
|
|
141
|
+
_setupInternalCallback() {
|
|
142
|
+
this.addon.setEventCallback((event) => {
|
|
143
|
+
this.emit('raw', event);
|
|
144
|
+
if (event.type === VivoxMessageType.Response)
|
|
145
|
+
this._handleResponse(event);
|
|
146
|
+
else if (event.type === VivoxMessageType.Event)
|
|
147
|
+
this._handleEvent(event);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
_handleResponse(event) {
|
|
151
|
+
const status = event.status ?? -1;
|
|
152
|
+
const payload = {
|
|
153
|
+
status,
|
|
154
|
+
status_name: exports.VivoxUtils.getErrorName(status),
|
|
155
|
+
status_string: event.status_string
|
|
156
|
+
};
|
|
157
|
+
switch (event.resp_type) {
|
|
158
|
+
case 1:
|
|
159
|
+
this.emit('connectorCreated', payload);
|
|
160
|
+
break;
|
|
161
|
+
case 131:
|
|
162
|
+
case 132:
|
|
163
|
+
if (status === 0)
|
|
164
|
+
this.emit('loginSuccess', payload);
|
|
165
|
+
else
|
|
166
|
+
this.emit('loginFailure', payload);
|
|
167
|
+
break;
|
|
168
|
+
case 8:
|
|
169
|
+
if (status === 0)
|
|
170
|
+
this.emit('joinSuccess', payload);
|
|
171
|
+
else
|
|
172
|
+
this.emit('joinFailure', payload);
|
|
173
|
+
break;
|
|
174
|
+
case 87:
|
|
175
|
+
this.emit('renderDevices', event.devices || []);
|
|
176
|
+
break;
|
|
177
|
+
case 88:
|
|
178
|
+
this.emit('captureDevices', event.devices || []);
|
|
179
|
+
break;
|
|
180
|
+
default: this.emit('response', event);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_handleEvent(event) {
|
|
184
|
+
switch (event.evt_type) {
|
|
185
|
+
case 2:
|
|
186
|
+
this.emit('loginStateChange', { state: event.state ?? 0, handle: event.account_handle ?? '' });
|
|
187
|
+
break;
|
|
188
|
+
case 26:
|
|
189
|
+
this.emit('participantAdded', { participant_uri: event.participant_uri ?? '', is_current_user: event.is_current_user === 1 });
|
|
190
|
+
break;
|
|
191
|
+
case 27:
|
|
192
|
+
this.emit('participantRemoved', { participant_uri: event.participant_uri ?? '', reason: event.reason ?? 0 });
|
|
193
|
+
break;
|
|
194
|
+
case 28:
|
|
195
|
+
this.emit('participantUpdated', { participant_uri: event.participant_uri ?? '', is_speaking: event.is_speaking === 1, energy: event.energy ?? 0 });
|
|
196
|
+
break;
|
|
197
|
+
case 53:
|
|
198
|
+
this.emit('connectionStateChanged', event.connection_state ?? 0);
|
|
199
|
+
break;
|
|
200
|
+
case 10:
|
|
201
|
+
this.emit('message', { participant_uri: event.participant_uri ?? '', message: event.message ?? '', session_handle: event.session_handle ?? '' });
|
|
202
|
+
break;
|
|
203
|
+
default: this.emit('event', event);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// --- SDK Methods ---
|
|
207
|
+
connectorCreate(server, handle = "default") { return this.addon.connectorCreate(server, handle); }
|
|
208
|
+
login(connectorHandle, accountUri, token) { return this.addon.login(connectorHandle, accountUri, token); }
|
|
209
|
+
loginAnonymous(connectorHandle, accountUri, token) { return this.addon.loginAnonymous(connectorHandle, accountUri, token); }
|
|
210
|
+
joinChannel(accountHandle, channelUri, token) { return this.addon.joinChannel(accountHandle, channelUri, token); }
|
|
211
|
+
sendMessage(sessionHandle, message) { return this.addon.sendMessage(sessionHandle, message); }
|
|
212
|
+
getCaptureDevices() { return this.addon.getCaptureDevices(); }
|
|
213
|
+
setCaptureDevice(deviceId) { return this.addon.setCaptureDevice(deviceId); }
|
|
214
|
+
getRenderDevices() { return this.addon.getRenderDevices(); }
|
|
215
|
+
setRenderDevice(deviceId) { return this.addon.setRenderDevice(deviceId); }
|
|
216
|
+
setLocalMicVolume(volume) { return this.addon.setLocalMicVolume(volume); }
|
|
217
|
+
setLocalSpeakerVolume(volume) { return this.addon.setLocalSpeakerVolume(volume); }
|
|
218
|
+
muteLocalMic(connectorHandle, mute) { return this.addon.muteLocalMic(connectorHandle, mute ? 1 : 0); }
|
|
219
|
+
setParticipantMute(sessionHandle, participantUri, mute) { return this.addon.setParticipantMuteForMe(sessionHandle, participantUri, mute ? 1 : 0); }
|
|
220
|
+
setParticipantVolume(sessionHandle, participantUri, volume) { return this.addon.setParticipantVolumeForMe(sessionHandle, participantUri, volume); }
|
|
221
|
+
muteUser(accountHandle, channelUri, participantUri, mute) { return this.addon.channelMuteUser(accountHandle, channelUri, participantUri, mute ? 1 : 0); }
|
|
222
|
+
kickUser(accountHandle, channelUri, participantUri) { return this.addon.kickUser(accountHandle, channelUri, participantUri); }
|
|
223
|
+
injectAudio(accountHandle, filename) { return this.addon.startAudioInjection(accountHandle, filename); }
|
|
224
|
+
stopAudioInjection(accountHandle) { return this.addon.stopAudioInjection(accountHandle); }
|
|
225
|
+
set3DPosition(accountHandle, posX, posY, posZ, channelUri) {
|
|
226
|
+
const sessionHandle = `${channelUri}_sess`;
|
|
227
|
+
return this.addon.set3DPosition(accountHandle, posX, posY, posZ, sessionHandle);
|
|
228
|
+
}
|
|
229
|
+
uninitialize() { this.initialized = false; this.addon.uninitialize(); }
|
|
230
|
+
}
|
|
231
|
+
exports.Vivox = Vivox;
|
|
232
|
+
/**
|
|
233
|
+
* Vivox Utility Fonksiyonları
|
|
234
|
+
*/
|
|
235
|
+
exports.VivoxUtils = {
|
|
236
|
+
getErrorName(statusCode) {
|
|
237
|
+
for (const [key, value] of Object.entries(VivoxError)) {
|
|
238
|
+
if (value === statusCode)
|
|
239
|
+
return key;
|
|
240
|
+
}
|
|
241
|
+
return `UNKNOWN_ERROR_${statusCode}`;
|
|
242
|
+
},
|
|
243
|
+
getLoginStateName(state) {
|
|
244
|
+
for (const [key, value] of Object.entries(VivoxLoginState)) {
|
|
245
|
+
if (value === state)
|
|
246
|
+
return key;
|
|
247
|
+
}
|
|
248
|
+
return `UNKNOWN_STATE_${state}`;
|
|
249
|
+
},
|
|
250
|
+
getConnectionStateName(state) {
|
|
251
|
+
for (const [key, value] of Object.entries(VivoxConnectionState)) {
|
|
252
|
+
if (value === state)
|
|
253
|
+
return key;
|
|
254
|
+
}
|
|
255
|
+
return `UNKNOWN_CONNECTION_STATE_${state}`;
|
|
256
|
+
},
|
|
257
|
+
generateAccountUri(domain, userId, environmentDomain) {
|
|
258
|
+
return `sip:.${domain}.${userId}.@${environmentDomain}`;
|
|
259
|
+
},
|
|
260
|
+
generateChannelUri(domain, channelId, environmentDomain) {
|
|
261
|
+
return `sip:confctl-g-${domain}.${channelId}@${environmentDomain}`;
|
|
262
|
+
},
|
|
263
|
+
generateSessionHandle(channelUri) {
|
|
264
|
+
return `${channelUri}_sess`;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const defaultInstance = new Vivox();
|
|
268
|
+
exports.default = defaultInstance;
|
|
269
|
+
module.exports = defaultInstance;
|
|
270
|
+
module.exports.Vivox = Vivox;
|
|
271
|
+
module.exports.VivoxUtils = exports.VivoxUtils;
|
|
272
|
+
module.exports.VivoxError = VivoxError;
|
|
273
|
+
module.exports.VivoxLoginState = VivoxLoginState;
|
|
274
|
+
module.exports.VivoxConnectionState = VivoxConnectionState;
|
|
275
|
+
module.exports.VivoxParticipantRemovedReason = VivoxParticipantRemovedReason;
|
|
276
|
+
module.exports.VivoxSessionMediaState = VivoxSessionMediaState;
|
|
277
|
+
module.exports.VivoxSessionTextState = VivoxSessionTextState;
|
|
278
|
+
module.exports.VivoxMessageType = VivoxMessageType;
|
|
279
|
+
module.exports.VivoxLogLevel = VivoxLogLevel;
|