@4players/odin-nodejs 0.9.0 → 0.9.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/cppsrc/odinclient.cpp
CHANGED
|
@@ -46,6 +46,7 @@ OdinClient::OdinClient(const Napi::CallbackInfo& info) : Napi::ObjectWrap<OdinCl
|
|
|
46
46
|
|
|
47
47
|
if (info.Length() < 1 || !info[0].IsString()) {
|
|
48
48
|
Napi::TypeError::New(env, "Access Key required as first parameter").ThrowAsJavaScriptException();
|
|
49
|
+
return;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
_accessKey = info[0].ToString().Utf8Value();
|
|
@@ -57,6 +58,7 @@ OdinClient::OdinClient(const Napi::CallbackInfo& info) : Napi::ObjectWrap<OdinCl
|
|
|
57
58
|
_sampleRate = info[1].ToNumber();
|
|
58
59
|
} else {
|
|
59
60
|
Napi::TypeError::New(env, "Sample rate must be a number").ThrowAsJavaScriptException();
|
|
61
|
+
return;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -65,6 +67,7 @@ OdinClient::OdinClient(const Napi::CallbackInfo& info) : Napi::ObjectWrap<OdinCl
|
|
|
65
67
|
_numChannels = info[2].ToNumber();
|
|
66
68
|
} else {
|
|
67
69
|
Napi::TypeError::New(env, "Channels must be a number").ThrowAsJavaScriptException();
|
|
70
|
+
return;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -98,6 +101,7 @@ Napi::Value OdinClient::GenerateAccessToken(const Napi::CallbackInfo &info)
|
|
|
98
101
|
|
|
99
102
|
if (info.Length() != 2 || !info[0].IsString() || !info[1].IsString()) {
|
|
100
103
|
Napi::TypeError::New(env, "Room and User Id expected").ThrowAsJavaScriptException();
|
|
104
|
+
return env.Undefined();
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
std::string roomId = info[0].ToString().Utf8Value();
|
|
@@ -107,6 +111,7 @@ Napi::Value OdinClient::GenerateAccessToken(const Napi::CallbackInfo &info)
|
|
|
107
111
|
if (!generator)
|
|
108
112
|
{
|
|
109
113
|
Napi::TypeError::New(env, "Failed to initialize token generator, invalid access key").ThrowAsJavaScriptException();
|
|
114
|
+
return env.Undefined();
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
/*
|
|
@@ -117,6 +122,7 @@ Napi::Value OdinClient::GenerateAccessToken(const Napi::CallbackInfo &info)
|
|
|
117
122
|
if (odin_is_error(error))
|
|
118
123
|
{
|
|
119
124
|
Napi::TypeError::New(env, "Creating access token failed").ThrowAsJavaScriptException();
|
|
125
|
+
return env.Undefined();
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
/*
|
|
@@ -137,6 +143,7 @@ Napi::Value OdinClient::CreateRoom(const Napi::CallbackInfo &info) {
|
|
|
137
143
|
|
|
138
144
|
if (info.Length() != 2 || !info[0].IsString() || !info[1].IsString()) {
|
|
139
145
|
Napi::TypeError::New(env, "Room and User Id expected").ThrowAsJavaScriptException();
|
|
146
|
+
return env.Undefined();
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
std::string roomId = info[0].ToString().Utf8Value();
|
package/cppsrc/odinmedia.cpp
CHANGED
|
@@ -25,6 +25,7 @@ Napi::Value OdinMedia::MediaId(const Napi::CallbackInfo &info) {
|
|
|
25
25
|
OdinReturnCode error = odin_media_stream_media_id(_mediaStreamHandle, &out_id);
|
|
26
26
|
if (odin_is_error(error)) {
|
|
27
27
|
Napi::TypeError::New(env, "Failed to get media id").ThrowAsJavaScriptException();
|
|
28
|
+
return env.Undefined();
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
return Napi::Number::New(env, out_id);
|
|
@@ -41,10 +42,12 @@ OdinMedia::OdinMedia(const Napi::CallbackInfo &info) : Napi::ObjectWrap<OdinMedi
|
|
|
41
42
|
// Checking for room instance, sample rate (float) and channels (int)
|
|
42
43
|
if (info.Length() < 3 || !info[0].IsObject() || !info[1].IsNumber() || !info[2].IsNumber()) {
|
|
43
44
|
Napi::TypeError::New(env, "Provide an OdinRoom instance, sample rate and number of channels as number").ThrowAsJavaScriptException();
|
|
45
|
+
return;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
if (info.Length() == 4 && !info[3].IsObject()) {
|
|
47
49
|
Napi::TypeError::New(env, "Options need to be provided as an object").ThrowAsJavaScriptException();
|
|
50
|
+
return;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
_room = Napi::ObjectWrap<OdinRoom>::Unwrap(info[0].As<Napi::Object>());
|
|
@@ -227,6 +230,7 @@ void OdinMedia::SendData(const Napi::CallbackInfo &info) {
|
|
|
227
230
|
|
|
228
231
|
if (info.Length() < 1 || !info[0].IsTypedArray()) {
|
|
229
232
|
Napi::TypeError::New(env, "TypedArray required as first parameter").ThrowAsJavaScriptException();
|
|
233
|
+
return;
|
|
230
234
|
}
|
|
231
235
|
|
|
232
236
|
Napi::Float32Array array = info[0].As<Napi::Float32Array>();
|
package/cppsrc/odinroom.cpp
CHANGED
|
@@ -114,6 +114,7 @@ Napi::Value OdinRoom::RoomId(const Napi::CallbackInfo &info) {
|
|
|
114
114
|
if (odin_is_error(error))
|
|
115
115
|
{
|
|
116
116
|
Napi::TypeError::New(env, "Failed to get room id").ThrowAsJavaScriptException();
|
|
117
|
+
return env.Undefined();
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
return Napi::String::New(env, out_id);
|
|
@@ -303,6 +304,7 @@ OdinRoom::OdinRoom(const Napi::CallbackInfo& info) :Napi::ObjectWrap<OdinRoom>(i
|
|
|
303
304
|
|
|
304
305
|
if (info.Length() != 1 || !info[0].IsString()) {
|
|
305
306
|
Napi::TypeError::New(env, "Provide a token to create a room").ThrowAsJavaScriptException();
|
|
307
|
+
return;
|
|
306
308
|
}
|
|
307
309
|
|
|
308
310
|
_token = info[0].ToString().Utf8Value();
|
|
@@ -377,6 +379,7 @@ void OdinRoom::UpdatePosition(const Napi::CallbackInfo &info)
|
|
|
377
379
|
|
|
378
380
|
if (info.Length() != 3 || !info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber()) {
|
|
379
381
|
Napi::TypeError::New(env, "Provide x, y and z coordinates as numbers").ThrowAsJavaScriptException();
|
|
382
|
+
return;
|
|
380
383
|
}
|
|
381
384
|
|
|
382
385
|
float x = info[0].ToNumber();
|
|
@@ -400,6 +403,7 @@ void OdinRoom::SetPositionScale(const Napi::CallbackInfo &info)
|
|
|
400
403
|
|
|
401
404
|
if (info.Length() != 1 || !info[0].IsNumber()) {
|
|
402
405
|
Napi::TypeError::New(env, "Provide scale as number").ThrowAsJavaScriptException();
|
|
406
|
+
return;
|
|
403
407
|
}
|
|
404
408
|
|
|
405
409
|
float scale = info[0].ToNumber();
|
|
@@ -420,6 +424,7 @@ void OdinRoom::Join(const Napi::CallbackInfo &info) {
|
|
|
420
424
|
|
|
421
425
|
if (info.Length() < 1) {
|
|
422
426
|
Napi::TypeError::New(env, "Gateway required as first parameter").ThrowAsJavaScriptException();
|
|
427
|
+
return;
|
|
423
428
|
}
|
|
424
429
|
|
|
425
430
|
std::string url = info[0].ToString().Utf8Value();
|
|
@@ -437,6 +442,7 @@ void OdinRoom::Join(const Napi::CallbackInfo &info) {
|
|
|
437
442
|
if (odin_is_error(error))
|
|
438
443
|
{
|
|
439
444
|
OdinUtilities::ThrowNapiException(env, error, "Failed to join room");
|
|
445
|
+
return;
|
|
440
446
|
}
|
|
441
447
|
|
|
442
448
|
_joined = true;
|
|
@@ -485,6 +491,7 @@ Napi::Value OdinRoom::CreateNewItem(const Napi::CallbackInfo& info) {
|
|
|
485
491
|
|
|
486
492
|
if (info.Length() < 1) {
|
|
487
493
|
Napi::TypeError::New(env, "Token required as first parameter").ThrowAsJavaScriptException();
|
|
494
|
+
return env.Undefined();
|
|
488
495
|
}
|
|
489
496
|
|
|
490
497
|
Napi::String token = info[0].ToString();
|
|
@@ -516,6 +523,7 @@ void OdinRoom::UpdatePeerUserData(const Napi::CallbackInfo &info) {
|
|
|
516
523
|
|
|
517
524
|
if (info.Length() != 1 || !info[0].IsTypedArray()) {
|
|
518
525
|
Napi::TypeError::New(env, "Data as byte array expected").ThrowAsJavaScriptException();
|
|
526
|
+
return;
|
|
519
527
|
}
|
|
520
528
|
|
|
521
529
|
Napi::Uint8Array data = info[0].As<Napi::Uint8Array>();
|
|
@@ -540,6 +548,7 @@ void OdinRoom::SendMessage(const Napi::CallbackInfo &info) {
|
|
|
540
548
|
|
|
541
549
|
if (info.Length() < 1 || !info[0].IsTypedArray()) {
|
|
542
550
|
Napi::TypeError::New(env, "Data as byte array expected").ThrowAsJavaScriptException();
|
|
551
|
+
return;
|
|
543
552
|
}
|
|
544
553
|
|
|
545
554
|
Napi::Uint8Array data = info[0].As<Napi::Uint8Array>();
|
|
@@ -581,6 +590,7 @@ void OdinRoom::SetEventListener(const Napi::CallbackInfo &info) {
|
|
|
581
590
|
|
|
582
591
|
if (info.Length() != 1 || !info[0].IsFunction()) {
|
|
583
592
|
Napi::TypeError::New(env, "Callback function expected").ThrowAsJavaScriptException();
|
|
593
|
+
return;
|
|
584
594
|
}
|
|
585
595
|
|
|
586
596
|
Napi::Function napiFunction = info[0].As<Napi::Function>();
|
|
@@ -598,6 +608,7 @@ void OdinRoom::AddEventListener(const Napi::CallbackInfo &info) {
|
|
|
598
608
|
|
|
599
609
|
if (info.Length() != 2 || !info[0].IsString() || !info[1].IsFunction()) {
|
|
600
610
|
Napi::TypeError::New(env, "Event Name and Callback function expected").ThrowAsJavaScriptException();
|
|
611
|
+
return;
|
|
601
612
|
}
|
|
602
613
|
|
|
603
614
|
std::string eventName = info[0].As<Napi::String>().Utf8Value();
|
|
@@ -632,6 +643,7 @@ void OdinRoom::RemoveEventListener(const Napi::CallbackInfo &info) {
|
|
|
632
643
|
|
|
633
644
|
if (info.Length() != 1 || !info[0].IsString()) {
|
|
634
645
|
Napi::TypeError::New(env, "Event Name expected").ThrowAsJavaScriptException();
|
|
646
|
+
return;
|
|
635
647
|
}
|
|
636
648
|
|
|
637
649
|
std::string eventName = info[0].As<Napi::String>().Utf8Value();
|
|
@@ -734,10 +746,12 @@ Napi::Value OdinRoom::CreateAudioStream(const Napi::CallbackInfo &info)
|
|
|
734
746
|
// Checking for input of sample rate (int) and number of channels (int)
|
|
735
747
|
if (info.Length() != 2 || !info[0].IsNumber() || !info[1].IsNumber()) {
|
|
736
748
|
Napi::TypeError::New(env, "Sample rate and number of channels expected").ThrowAsJavaScriptException();
|
|
749
|
+
return env.Undefined();
|
|
737
750
|
}
|
|
738
751
|
|
|
739
752
|
if (info.Length() == 3 && !info[2].IsObject()) {
|
|
740
753
|
Napi::TypeError::New(env, "Options need to be an object").ThrowAsJavaScriptException();
|
|
754
|
+
return env.Undefined();
|
|
741
755
|
}
|
|
742
756
|
|
|
743
757
|
if (info.Length() == 2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4players/odin-nodejs",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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
|