Skip to content

Commit c63e724

Browse files
committed
chore: bump version 10.9.50
Signed-off-by: Dylan <2894220@gmail.com>
1 parent f3a0053 commit c63e724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+555
-220
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if (UNIX)
1919
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2020
endif ()
2121
add_compile_options(-fvisibility=hidden)
22+
add_compile_options(-Wno-macro-redefined)
2223
endif ()
2324

2425
if (MSVC)
@@ -140,6 +141,8 @@ target_link_libraries(${TARGET_NAME}
140141
nim_tools_cpp_wrapper
141142
nim_qchat_cpp_wrapper
142143
nim_wrapper_util
144+
${CONAN_LIBS_GLOG}
145+
${CONAN_LIBS_GFLAGS}
143146
${CONAN_LIBS_NE_CHROMIUM_BASE}
144147
${CONAN_LIBS_OPENSSL}
145148
)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-nim",
3-
"version": "10.9.41",
3+
"version": "10.9.50",
44
"description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
55
"main": "dist/node-nim.js",
66
"bin": {

src/callback_specialization.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ CallbackSpecialization(V2NIMSuccessCallback<V2NIMP2PMessageReadReceipt>);
178178
CallbackSpecialization(V2NIMSuccessCallback<V2NIMCollection>);
179179
CallbackSpecialization(V2NIMSuccessCallback<V2NIMSendMessageResult>);
180180
CallbackSpecialization(V2NIMSuccessCallback<const V2NIMCreateTeamResult&>);
181+
using V2NIMCallbackSpecializationTempType5 = nstd::map<V2NIMTeamRefer, nstd::vector<V2NIMTeamMember>>;
182+
CallbackSpecialization(V2NIMSuccessCallback<const V2NIMCallbackSpecializationTempType5&>);
181183
CallbackSpecialization(V2NIMSuccessCallback<const V2NIMTeam&>);
182184
CallbackSpecialization(V2NIMSuccessCallback<const V2NIMTeamMemberListResult&>);
183185
CallbackSpecialization(V2NIMSuccessCallback<nstd::vector<nstd::string>>);

src/cpp_invoker.h

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
#ifndef SRC_CPP_INVOKER_H_
1111
#define SRC_CPP_INVOKER_H_
1212

13-
#include <extension/device/platform_device.h>
14-
#include <extension/util/uuid.h>
13+
#include <glog/logging.h>
1514
#include <napi.h>
16-
1715
#include <thread>
1816
#include <tuple>
1917
#include "extension/log/log.h"
2018
#include "ts_cpp_conversion.h"
19+
#include "utilities.h"
2120

2221
struct CppInvoker {
2322
public:
@@ -116,12 +115,16 @@ struct CppInvoker {
116115
auto thread_id = std::this_thread::get_id();
117116
auto tsfn = Napi::ThreadSafeFunction::New(env, fun, fun_location_name, 0, 1);
118117
auto callback = [=](TArgs... param) -> TReturn {
119-
auto uuid = base::extension::UUIDGenerate();
118+
auto uuid = node_nim::Utilities::GenerateUUID();
120119
auto tup = std::make_tuple(std::forward<TArgs>(param)...);
121120
if constexpr (!std::is_void<TReturn>::value) {
122121
if (std::this_thread::get_id() == thread_id) {
123122
// nodejs thread, call directly
124-
// QLOG_APP("[ToThreadSafeCallback - 0] Call in Node.js thread, function: {0}") << fun_location_name;
123+
#if defined(USING_NIM_LOG)
124+
QLOG_APP("[ToThreadSafeCallback - 0] Call in Node.js thread, function: {0}") << fun_location_name;
125+
#else
126+
LOG(INFO) << "[ToThreadSafeCallback - 0] Call in Node.js thread, function: " << fun_location_name;
127+
#endif
125128
auto&& args = TupleToCbArgs(env, tup);
126129
auto return_value = fun.Call(args);
127130
return ts_cpp_conversion::ObjectToStruct<TReturn>(env, return_value, -1);
@@ -131,8 +134,13 @@ struct CppInvoker {
131134
auto tsfn_cb = [tup, &promise, fun_location_name, uuid](
132135
const Napi::Env& env, const Napi::Function& js_callback, const void* value) -> Napi::Value {
133136
try {
134-
// QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall with promise function running: {0}, uuid: {1}")
135-
// << fun_location_name << uuid;
137+
#if defined(USING_NIM_LOG)
138+
QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall with promise function running: {0}, uuid: {1}")
139+
<< fun_location_name << uuid;
140+
#else
141+
LOG(INFO) << "[ToThreadSafeCallback - 0] NonBlockingCall with promise function running: " << fun_location_name
142+
<< ", uuid: " << uuid;
143+
#endif
136144
auto&& args = TupleToCbArgs(env, tup);
137145
auto return_value = js_callback.Call(args);
138146
promise.set_value(ts_cpp_conversion::ObjectToStruct<TReturn>(env, return_value, -1));
@@ -141,31 +149,51 @@ struct CppInvoker {
141149
}
142150
return env.Null();
143151
};
144-
// QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall with promise function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
152+
#if defined(USING_NIM_LOG)
153+
QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall with promise function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
145154
tsfn.NonBlockingCall((void*)0, tsfn_cb);
155+
#else
156+
LOG(INFO) << "[ToThreadSafeCallback - 0] NonBlockingCall with promise function dispatch: " << fun_location_name << ", uuid: " << uuid;
157+
#endif
146158
auto result = future.get();
147-
// QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall with promise function done: {0}, uuid: {1}") << fun_location_name << uuid;
159+
#if defined(USING_NIM_LOG)
160+
QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall with promise function done: {0}, uuid: {1}") << fun_location_name << uuid;
161+
#else
162+
LOG(INFO) << "[ToThreadSafeCallback - 0] NonBlockingCall with promise function done: " << fun_location_name << ", uuid: " << uuid;
163+
#endif
148164
return result;
149165
} else {
150166
if (std::this_thread::get_id() == thread_id) {
151167
// nodejs thread, call directly
152-
// QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall in Node.js thread, function: {0}") << fun_location_name;
168+
#if defined(USING_NIM_LOG)
169+
QLOG_APP("[ToThreadSafeCallback - 0] Call in Node.js thread, function: {0}") << fun_location_name;
170+
#else
171+
LOG(INFO) << "[ToThreadSafeCallback - 0] Call in Node.js thread, function: " << fun_location_name;
172+
#endif
153173
auto&& args = TupleToCbArgs(env, tup);
154174
fun.Call(args);
155175
return;
156176
}
157177
auto tsfn_cb = [tup, fun_location_name, uuid](
158178
const Napi::Env& env, const Napi::Function& js_callback, const void* value) -> Napi::Value {
159179
try {
160-
// QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall function running: {0}, uuid: {1}") << fun_location_name << uuid;
180+
#if defined(USING_NIM_LOG)
181+
QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall function running: {0}, uuid: {1}") << fun_location_name << uuid;
182+
#else
183+
LOG(INFO) << "[ToThreadSafeCallback - 0] NonBlockingCall function running: " << fun_location_name << ", uuid: " << uuid;
184+
#endif
161185
auto&& args = TupleToCbArgs(env, tup);
162186
js_callback.Call(args);
163187
} catch (const std::exception& e) {
164188
Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
165189
}
166190
return env.Null();
167191
};
168-
// QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
192+
#if defined(USING_NIM_LOG)
193+
QLOG_APP("[ToThreadSafeCallback - 0] NonBlockingCall function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
194+
#else
195+
LOG(INFO) << "[ToThreadSafeCallback - 0] NonBlockingCall function dispatch: " << fun_location_name << ", uuid: " << uuid;
196+
#endif
169197
tsfn.NonBlockingCall((void*)0, tsfn_cb);
170198
}
171199
};
@@ -183,12 +211,16 @@ struct CppInvoker {
183211
auto thread_id = std::this_thread::get_id();
184212
auto tsfn = Napi::ThreadSafeFunction::New(env, fun, fun_location_name, 0, 1);
185213
auto callback = [=](TArgs... param) -> TReturn {
186-
auto uuid = base::extension::UUIDGenerate();
214+
auto uuid = node_nim::Utilities::GenerateUUID();
187215
auto tup = std::make_tuple(std::forward<TArgs>(param)...);
188216
if constexpr (!std::is_void<TReturn>::value) {
189217
if (std::this_thread::get_id() == thread_id) {
190218
// nodejs thread, call directly
191-
// QLOG_APP("[ToThreadSafeCallback - 1] Call in Node.js thread, function: {0}") << fun_location_name;
219+
#if defined(USING_NIM_LOG)
220+
QLOG_APP("[ToThreadSafeCallback - 1] Call in Node.js thread, function: {0}") << fun_location_name;
221+
#else
222+
LOG(INFO) << "[ToThreadSafeCallback - 1] Call in Node.js thread, function: " << fun_location_name;
223+
#endif
192224
auto&& args = TupleToCbArgs(env, tup);
193225
auto return_value = fun.Call(args);
194226
return ts_cpp_conversion::ObjectToStruct<TReturn>(env, return_value, -1);
@@ -198,8 +230,13 @@ struct CppInvoker {
198230
auto tsfn_cb = [tup, &promise, fun_location_name, uuid](
199231
const Napi::Env& env, const Napi::Function& js_callback, const void* value) -> Napi::Value {
200232
try {
201-
// QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall with promise function running: {0}, uuid: {1}")
202-
// << fun_location_name << uuid;
233+
#if defined(USING_NIM_LOG)
234+
QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall with promise function running: {0}, uuid: {1}")
235+
<< fun_location_name << uuid;
236+
#else
237+
LOG(INFO) << "[ToThreadSafeCallback - 1] NonBlockingCall with promise function running: " << fun_location_name
238+
<< ", uuid: " << uuid;
239+
#endif
203240
auto&& args = TupleToCbArgs(env, tup);
204241
auto return_value = js_callback.Call(args);
205242
promise.set_value(ts_cpp_conversion::ObjectToStruct<TReturn>(env, return_value, -1));
@@ -208,31 +245,51 @@ struct CppInvoker {
208245
}
209246
return env.Null();
210247
};
211-
// QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall with promise function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
248+
#if defined(USING_NIM_LOG)
249+
QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall with promise function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
250+
#else
251+
LOG(INFO) << "[ToThreadSafeCallback - 1] NonBlockingCall with promise function dispatch: " << fun_location_name << ", uuid: " << uuid;
252+
#endif
212253
tsfn.NonBlockingCall((void*)0, tsfn_cb);
213254
auto result = future.get();
214-
// QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall with promise function done: {0}, uuid: {1}") << fun_location_name << uuid;
255+
#if defined(USING_NIM_LOG)
256+
QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall with promise function done: {0}, uuid: {1}") << fun_location_name << uuid;
257+
#else
258+
LOG(INFO) << "[ToThreadSafeCallback - 1] NonBlockingCall with promise function done: " << fun_location_name << ", uuid: " << uuid;
259+
#endif
215260
return result;
216261
} else {
217262
if (std::this_thread::get_id() == thread_id) {
218263
// nodejs thread, call directly
219-
// QLOG_APP("[ToThreadSafeCallback - 1] Call in Node.js thread, function: {0}") << fun_location_name;
264+
#if defined(USING_NIM_LOG)
265+
QLOG_APP("[ToThreadSafeCallback - 1] Call in Node.js thread, function: {0}") << fun_location_name;
266+
#else
267+
LOG(INFO) << "[ToThreadSafeCallback - 1] Call in Node.js thread, function: " << fun_location_name;
268+
#endif
220269
auto&& args = TupleToCbArgs(env, tup);
221270
fun.Call(args);
222271
return;
223272
}
224273
auto tsfn_cb = [tup, fun_location_name, uuid](
225274
const Napi::Env& env, const Napi::Function& js_callback, const void* value) -> Napi::Value {
226275
try {
227-
// QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall function running: {0}, uuid: {1}") << fun_location_name << uuid;
276+
#if defined(USING_NIM_LOG)
277+
QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall function running: {0}, uuid: {1}") << fun_location_name << uuid;
278+
#else
279+
LOG(INFO) << "[ToThreadSafeCallback - 1] NonBlockingCall function running: " << fun_location_name << ", uuid: " << uuid;
280+
#endif
228281
auto&& args = TupleToCbArgs(env, tup);
229282
js_callback.Call(args);
230283
} catch (const std::exception& e) {
231284
Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
232285
}
233286
return env.Null();
234287
};
235-
// QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
288+
#if defined(USING_NIM_LOG)
289+
QLOG_APP("[ToThreadSafeCallback - 1] NonBlockingCall function dispatch: {0}, uuid: {1}") << fun_location_name << uuid;
290+
#else
291+
LOG(INFO) << "[ToThreadSafeCallback - 1] NonBlockingCall function dispatch: " << fun_location_name << ", uuid: " << uuid;
292+
#endif
236293
tsfn.NonBlockingCall((void*)0, tsfn_cb);
237294
}
238295
};

src/entry.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
#include <napi.h>
88
#include "chatroom/chatroom.h"
9-
#include "extension/log/log.h"
109
#include "extension/util/init.h"
1110
#include "nim/ai/nim_node_ai.h"
1211
#include "nim/client/nim_node_client.h"
@@ -62,8 +61,6 @@
6261

6362
namespace {
6463

65-
// std::shared_ptr<base::AtExitManager> at_exit_ = nullptr;
66-
6764
#if defined(WIN32) || defined(_WIN32)
6865
std::wstring GetNodeModulePath() {
6966
TCHAR dllPath[MAX_PATH];
@@ -88,8 +85,14 @@ std::wstring GetNodeModuleDirectory() {
8885
}
8986
#endif
9087

88+
#if defined(USING_NIM_LOG)
89+
std::shared_ptr<base::AtExitManager> at_exit_ = nullptr;
90+
#endif
91+
9192
Napi::Object RegisterModule(Napi::Env env, Napi::Object exports) {
92-
// at_exit_ = base::extension::getAtExitManager();
93+
#if defined(USING_NIM_LOG)
94+
at_exit_ = base::extension::getAtExitManager();
95+
#endif
9396
Napi::HandleScope scope(env);
9497
node_nim::NIMChatRoom::Init(env, exports);
9598
node_nim::NIMClient::Init(env, exports);

src/service_base.h

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <utility>
1717
#include <vector>
1818
#include "extension/log/log.h"
19+
#include "utilities.h"
1920
// clang-format off
2021
#include "reflection/reflection_include.h"
2122
#include "callback_specialization.h"
@@ -172,34 +173,50 @@ class BizService : public ServiceBase, public Napi::ObjectWrap<TSubClass> {
172173

173174
template <typename TR, typename... Args, typename std::enable_if<std::is_void<TR>::value, std::nullptr_t>::type = nullptr>
174175
TR NotifyCallback(const std::string& flag, Args... args) {
175-
auto uuid = base::extension::UUIDGenerate();
176+
auto uuid = node_nim::Utilities::GenerateUUID();
176177
auto callback = [this, flag, uuid, args...](const Napi::Env& env, const Napi::Function& js_callback, const void* value) {
177178
try {
178-
// QLOG_APP("[TR NotifyCallback - 0] running flag: {0}, uuid: {1}") << flag << uuid;
179+
#if defined(USING_NIM_LOG)
180+
QLOG_APP("[TR NotifyCallback - 0] running flag: {0}, uuid: {1}") << flag << uuid;
181+
#else
182+
LOG(INFO) << "[TR NotifyCallback - 0] running flag: " << flag << ", uuid: " << uuid;
183+
#endif
179184
Napi::Value res = emitter_.Call({Napi::String::New(env, flag), ts_cpp_conversion::StructToObject(env, args)...});
180185
} catch (const std::exception& error) {
181186
Napi::Error::New(env, error.what()).ThrowAsJavaScriptException();
182187
}
183188
};
184-
// QLOG_APP("[TR NotifyCallback - 0] dispatch flag: {0}, uuid: {1}") << flag << uuid;
189+
#if defined(USING_NIM_LOG)
190+
QLOG_APP("[TR NotifyCallback - 0] dispatch flag: {0}, uuid: {1}") << flag << uuid;
191+
#else
192+
LOG(INFO) << "[TR NotifyCallback - 0] dispatch flag: " << flag << ", uuid: " << uuid;
193+
#endif
185194
tsfn_.NonBlockingCall(reinterpret_cast<void*>(0), callback);
186195
}
187196

188197
template <typename TR, typename... Args, typename std::enable_if<!std::is_void<TR>::value, std::nullptr_t>::type = nullptr>
189198
TR NotifyCallback(const std::string& flag, Args... args) {
190-
auto uuid = base::extension::UUIDGenerate();
199+
auto uuid = node_nim::Utilities::GenerateUUID();
191200
std::promise<TR> promise;
192201
std::future<TR> future = promise.get_future();
193202
auto callback = [this, flag, uuid, &promise, args...](const Napi::Env& env, const Napi::Function& js_callback, const void* value) {
194203
try {
195-
// QLOG_APP("[TR NotifyCallback 1] running flag: {0}, uuid: {1}") << flag << uuid;
204+
#if defined(USING_NIM_LOG)
205+
QLOG_APP("[TR NotifyCallback 1] running flag: {0}, uuid: {1}") << flag << uuid;
206+
#else
207+
LOG(INFO) << "[TR NotifyCallback 1] running flag: " << flag << ", uuid: " << uuid;
208+
#endif
196209
Napi::Value res = emitter_.Call({Napi::String::New(env, flag), ts_cpp_conversion::StructToObject(env, args)...});
197210
promise.set_value(ts_cpp_conversion::ObjectToStruct<TR>(env, res, -1));
198211
} catch (const std::exception& error) {
199212
Napi::Error::New(env, error.what()).ThrowAsJavaScriptException();
200213
}
201214
};
202-
// QLOG_APP("[TR NotifyCallback 1] dispatch flag: {0}, uuid: {1}") << flag << uuid;
215+
#if defined(USING_NIM_LOG)
216+
QLOG_APP("[TR NotifyCallback 1] dispatch flag: {0}, uuid: {1}") << flag << uuid;
217+
#else
218+
LOG(INFO) << "[TR NotifyCallback 1] dispatch flag: " << flag << ", uuid: " << uuid;
219+
#endif
203220
tsfn_.NonBlockingCall(reinterpret_cast<void*>(0), callback);
204221
return future.get();
205222
}

src/utilities.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @file utilities.cpp
3+
* @author Dylan (dengjiajia@corp.netease.com)
4+
* @brief
5+
* @date 2025/8/22
6+
*/
7+
8+
#include "utilities.h"
9+
#include <iomanip>
10+
#include <random>
11+
#include <sstream>
12+
13+
namespace node_nim {
14+
15+
std::string Utilities::GenerateUUID() {
16+
std::random_device rd;
17+
std::mt19937 gen(rd());
18+
std::uniform_int_distribution<> dis(0, 15);
19+
std::uniform_int_distribution<> dis2(8, 11);
20+
21+
std::stringstream ss;
22+
ss << std::hex;
23+
24+
for (int i = 0; i < 8; i++) {
25+
ss << dis(gen);
26+
}
27+
ss << "-";
28+
for (int i = 0; i < 4; i++) {
29+
ss << dis(gen);
30+
}
31+
ss << "-4"; // UUID version 4
32+
for (int i = 0; i < 3; i++) {
33+
ss << dis(gen);
34+
}
35+
ss << "-";
36+
ss << dis2(gen); // UUID variant
37+
for (int i = 0; i < 3; i++) {
38+
ss << dis(gen);
39+
}
40+
ss << "-";
41+
for (int i = 0; i < 12; i++) {
42+
ss << dis(gen);
43+
}
44+
45+
return ss.str();
46+
}
47+
48+
} // namespace node_nim

0 commit comments

Comments
 (0)