diff --git a/.gitignore b/.gitignore
index d540d77..9583cd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,9 @@
#/.packages
#/.dart_tool
#/example/ios/Podfile.lock
+build/
+.dart_tool/
+.vscode/
+.metadata
+.idea/encodings.xml
+.idea/other.xml
diff --git a/.idea/flutter_openim_sdk.iml b/.idea/flutter_openim_sdk.iml
index f66f4f5..956868f 100644
--- a/.idea/flutter_openim_sdk.iml
+++ b/.idea/flutter_openim_sdk.iml
@@ -123,6 +123,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/OpenIM_v3_3e8b8fb2ecd8414db50838d9f7bcb19d.db b/example/OpenIM_v3_3e8b8fb2ecd8414db50838d9f7bcb19d.db
deleted file mode 100644
index 929664c..0000000
Binary files a/example/OpenIM_v3_3e8b8fb2ecd8414db50838d9f7bcb19d.db and /dev/null differ
diff --git a/example/integration_test/plugin_integration_test.dart b/example/integration_test/plugin_integration_test.dart
index 3d9044c..887d2c3 100644
--- a/example/integration_test/plugin_integration_test.dart
+++ b/example/integration_test/plugin_integration_test.dart
@@ -6,12 +6,9 @@
// For more information about Flutter integration tests, please see
// https://flutter.dev/to/integration-testing
-
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
-import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
-
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 05da347..cd75dd9 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -3,7 +3,7 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
void main() {
try {
- runApp(MyApp());
+ runApp(const MyApp());
} catch (e, stackTrace) {
print('Error during app startup: $e');
print('Stack trace: $stackTrace');
@@ -11,6 +11,8 @@ void main() {
}
class MyApp extends StatefulWidget {
+ const MyApp({super.key});
+
@override
_MyAppState createState() => _MyAppState();
}
@@ -21,7 +23,7 @@ class _MyAppState extends State {
super.initState();
OpenIM.iMManager
.initSDK(
- platformID: 1,
+ platformID: 2,
apiAddr: 'http://192.168.77.135:10002',
wsAddr: 'ws://192.168.77.135:10001',
dataDir: './',
@@ -50,7 +52,7 @@ class _MyAppState extends State {
),
body: Column(
children: [
- TextButton(onPressed: () {}, child: Text('login')),
+ TextButton(onPressed: () {}, child: const Text('login')),
],
),
),
diff --git a/example/pubspec.lock b/example/pubspec.lock
index c110d01..56cbd94 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -5,42 +5,42 @@ packages:
dependency: transitive
description:
name: async
- sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
+ sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
- version: "2.12.0"
+ version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
- sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
+ sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
- version: "2.1.2"
+ version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
- sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
+ sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
- version: "1.4.0"
+ version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
- sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
+ sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
- version: "1.1.2"
+ version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
- sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
+ sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
- version: "1.19.1"
+ version: "1.18.0"
cupertino_icons:
dependency: "direct main"
description:
@@ -53,10 +53,10 @@ packages:
dependency: transitive
description:
name: fake_async
- sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
+ sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
- version: "1.3.2"
+ version: "1.3.1"
flutter:
dependency: "direct main"
description: flutter
@@ -86,18 +86,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
- sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
+ sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
- version: "10.0.8"
+ version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
- sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
+ sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
- version: "3.0.9"
+ version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
@@ -118,10 +118,10 @@ packages:
dependency: transitive
description:
name: matcher
- sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
+ sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
- version: "0.12.17"
+ version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
@@ -134,71 +134,71 @@ packages:
dependency: transitive
description:
name: meta
- sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
+ sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
- version: "1.16.0"
+ version: "1.15.0"
path:
dependency: transitive
description:
name: path
- sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
+ sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
- version: "1.9.1"
+ version: "1.9.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
- version: "0.0.0"
+ version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
- sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
+ sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
- version: "1.10.1"
+ version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
- sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
+ sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
- version: "1.12.1"
+ version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
- sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
+ sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
- version: "2.1.4"
+ version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
- sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
+ sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
- version: "1.4.1"
+ version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
- sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
+ sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
- version: "1.2.2"
+ version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
- sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
+ sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
- version: "0.7.4"
+ version: "0.7.2"
vector_math:
dependency: transitive
description:
@@ -211,10 +211,10 @@ packages:
dependency: transitive
description:
name: vm_service
- sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
+ sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
- version: "14.3.1"
+ version: "14.2.5"
sdks:
- dart: ">=3.7.0-0 <4.0.0"
+ dart: ">=3.4.4 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
index f376c56..48ebcae 100644
--- a/example/test/widget_test.dart
+++ b/example/test/widget_test.dart
@@ -13,7 +13,7 @@ import 'package:flutter_openim_sdk_example/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
- await tester.pumpWidget(MyApp());
+ await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
diff --git a/lib/src/manager/im_channel_manager.dart b/lib/src/manager/im_channel_manager.dart
index 5a3375d..a3e4f61 100644
--- a/lib/src/manager/im_channel_manager.dart
+++ b/lib/src/manager/im_channel_manager.dart
@@ -2,10 +2,6 @@ import 'dart:developer';
import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
-import 'package:flutter_openim_sdk/src/models/set_channel_member_info.dart';
-
-import '../listener/channel_listener.dart';
-import '../models/channel_info.dart';
class ChannelManager {
MethodChannel _channel;
diff --git a/lib/src/manager/im_conversation_manager.dart b/lib/src/manager/im_conversation_manager.dart
index cbbb6b2..ea89c24 100644
--- a/lib/src/manager/im_conversation_manager.dart
+++ b/lib/src/manager/im_conversation_manager.dart
@@ -4,7 +4,6 @@ import 'dart:developer';
import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
-import '../models/update_req.dart';
class ConversationManager {
MethodChannel _channel;
diff --git a/lib/src/manager/im_friendship_manager.dart b/lib/src/manager/im_friendship_manager.dart
index e132805..71211e7 100644
--- a/lib/src/manager/im_friendship_manager.dart
+++ b/lib/src/manager/im_friendship_manager.dart
@@ -3,7 +3,6 @@ import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
-import '../models/update_req.dart';
class FriendshipManager {
MethodChannel _channel;
diff --git a/lib/src/manager/im_group_manager.dart b/lib/src/manager/im_group_manager.dart
index 5cf15a3..8d0d447 100644
--- a/lib/src/manager/im_group_manager.dart
+++ b/lib/src/manager/im_group_manager.dart
@@ -2,7 +2,6 @@ import 'dart:developer';
import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
-import 'package:flutter_openim_sdk/src/models/set_group_member_info.dart';
class GroupManager {
MethodChannel _channel;
diff --git a/lib/src/manager/im_manager.dart b/lib/src/manager/im_manager.dart
index 5ed01e4..fee0103 100644
--- a/lib/src/manager/im_manager.dart
+++ b/lib/src/manager/im_manager.dart
@@ -6,8 +6,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
import 'package:flutter_openim_sdk/src/logger.dart';
-import '../models/channel_info.dart';
-import 'im_channel_manager.dart';
class IMManager {
MethodChannel _channel;
diff --git a/lib/src/models/notification_info.dart b/lib/src/models/notification_info.dart
index 2ecc5e6..ff98fea 100644
--- a/lib/src/models/notification_info.dart
+++ b/lib/src/models/notification_info.dart
@@ -1,5 +1,4 @@
import '../../flutter_openim_sdk.dart';
-import 'channel_info.dart';
/// OA notification
class OANotification {
@@ -456,8 +455,6 @@ class GroupMemberInfoChangedNotification {
}
}
-
-
///todo 所有的聊天的操作者都没有,暂时没有处理
/// 聊天室事件通知
class ChannelNotification {
@@ -481,7 +478,8 @@ class ChannelNotification {
});
ChannelNotification.fromJson(Map json) {
- Channel = json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
+ Channel =
+ json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
opUser = json['opUser'] != null
? ChannelMembersInfo.fromJson(json['opUser'])
: null;
@@ -514,7 +512,6 @@ class ChannelNotification {
}
}
-
/// 组踢出成员通知
class KickedChannelMemeberNotification {
/// 聊天室信息
@@ -530,7 +527,8 @@ class KickedChannelMemeberNotification {
{this.Channel, this.opUser, this.kickedUserList});
KickedChannelMemeberNotification.fromJson(Map json) {
- Channel = json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
+ Channel =
+ json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
opUser = json['opUser'] != null
? ChannelMembersInfo.fromJson(json['opUser'])
: null;
@@ -569,7 +567,8 @@ class QuitChannelNotification {
QuitChannelNotification({this.Channel, this.quitUser});
QuitChannelNotification.fromJson(Map json) {
- Channel = json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
+ Channel =
+ json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
quitUser = json['quitUser'] != null
? ChannelMembersInfo.fromJson(json['quitUser'])
: null;
@@ -598,7 +597,8 @@ class EnterChannelNotification {
EnterChannelNotification({this.Channel, this.entrantUser});
EnterChannelNotification.fromJson(Map json) {
- Channel = json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
+ Channel =
+ json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
entrantUser = json['entrantUser'] != null
? ChannelMembersInfo.fromJson(json['entrantUser'])
: null;
@@ -616,7 +616,6 @@ class EnterChannelNotification {
}
}
-
/// 禁言成员通知
class MuteChannelMemberNotification {
/// 聊天室信息
@@ -639,7 +638,8 @@ class MuteChannelMemberNotification {
});
MuteChannelMemberNotification.fromJson(Map json) {
- Channel = json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
+ Channel =
+ json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
opUser = json['opUser'] != null
? ChannelMembersInfo.fromJson(json['opUser'])
: null;
@@ -683,7 +683,8 @@ class ChannelMemberInfoChangedNotification {
});
ChannelMemberInfoChangedNotification.fromJson(Map json) {
- Channel = json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
+ Channel =
+ json['channel'] != null ? ChannelInfo.fromJson(json['channel']) : null;
opUser = json['opUser'] != null
? ChannelMembersInfo.fromJson(json['opUser'])
: null;
diff --git a/windows/flutter_openim_sdk_plugin.cpp b/windows/flutter_openim_sdk_plugin.cpp
index 4794fb8..e663829 100644
--- a/windows/flutter_openim_sdk_plugin.cpp
+++ b/windows/flutter_openim_sdk_plugin.cpp
@@ -14,6 +14,7 @@
#include
#include "src/MethodCallHandlerImpl.h"
#include "src/common/stable.h"
+#include "src/common/ThreadUtil.h"
class FlutterOpenimSdkPlugin : public flutter::Plugin {
@@ -68,6 +69,11 @@ void FlutterOpenimSdkPlugin::RegisterWithRegistrar(
NimCore::getInstance()->setLogDir(filePath);
+ // Initialize ThreadUtil to capture the platform thread ID
+ // This is called on the platform thread already, so it will initialize correctly
+ ThreadUtil::InitializePlatformThreadId();
+ YXLOG_API(Info) << "ThreadUtil initialized on platform thread" << YXLOGEnd;
+
auto plugin = std::make_unique();
auto channel = plugin->m_channel->startListening(registrar);
channel->SetMethodCallHandler(
diff --git a/windows/src/NimCore.cpp b/windows/src/NimCore.cpp
index ae4e4c2..497ca29 100644
--- a/windows/src/NimCore.cpp
+++ b/windows/src/NimCore.cpp
@@ -10,8 +10,15 @@
#include
#include "FLTConvert.h"
-
+#include "common/ThreadUtil.h"
#include "common/services/IMManager.h"
+#include "common/services/UserManager.h"
+#include "common/services/FriendManager.h"
+#include "common/services/MessageManager.h"
+#include "common/services/GroupManager.h"
+#include "common/services/ChannelManager.h"
+#include "common/services/ConversationManager.h"
+#include "common/stable.h"
const std::string kFLTNimCoreService = "serviceName";
@@ -22,7 +29,12 @@ NimCore::~NimCore() {}
void NimCore::regService() {
addService(new IMManagerService());
-
+ addService(new UserManagerService());
+ addService(new FriendshipManagerService());
+ addService(new MessageManagerService());
+ addService(new GroupManagerService());
+ addService(new ChannelManagerService());
+ addService(new ConversationManagerService());
}
void NimCore::cleanService() {
@@ -85,8 +97,9 @@ void NimCore::onMethodCall(
void NimCore::invokeMethod(const std::string& method,
const flutter::EncodableMap& arguments) {
if (m_channel) {
- m_channel->InvokeMethod(
- method, std::make_unique(arguments));
+ // Use ThreadUtil to ensure we're on the platform thread
+ ThreadUtil::InvokeMethodOnPlatformThread(
+ m_channel, method, std::make_unique(arguments));
}
}
@@ -115,9 +128,16 @@ void NimCore::invokeMethod(const std::string& eventName,
const InvokeMehtodCallback& callback) {
invokeCallback = callback;
if (m_channel) {
- m_channel->InvokeMethod(
- eventName, std::make_unique(arguments),
- std::make_unique>());
+ // Create shared pointers for the data to ensure copy constructibility
+ auto eventNameCopy = std::make_shared(eventName);
+ auto argsCopy = std::make_shared(arguments);
+
+ // Use ThreadUtil to ensure we're on the platform thread
+ ThreadUtil::RunOnPlatformThread([this, eventNameCopy, argsCopy]() {
+ m_channel->InvokeMethod(
+ *eventNameCopy, std::make_unique(*argsCopy),
+ std::make_unique>());
+ });
}
}
diff --git a/windows/src/common/FLTService.cpp b/windows/src/common/FLTService.cpp
index 1f1ca4e..115e710 100644
--- a/windows/src/common/FLTService.cpp
+++ b/windows/src/common/FLTService.cpp
@@ -5,6 +5,7 @@
#include "FLTService.h"
#include "../FLTConvert.h"
+#include "ThreadUtil.h"
std::string FLTService::getServiceName() const { return m_serviceName; }
@@ -22,8 +23,16 @@ void notifyEvent(const std::string& eventName,
for (auto& it : logList) {
YXLOG_API(Info) << it << YXLOGEnd;
}
- NimCore::getInstance()->invokeMethod(eventName, arguments);
- YXLOG_API(Info) << "notifyEvent invoke completation." << YXLOGEnd;
+
+ // Create shared pointers for the data to ensure copy constructibility
+ auto eventNameCopy = std::make_shared(eventName);
+ auto argsCopy = std::make_shared(arguments);
+
+ // Ensure we're on the platform thread
+ ThreadUtil::RunOnPlatformThread([eventNameCopy, argsCopy]() {
+ NimCore::getInstance()->invokeMethod(*eventNameCopy, *argsCopy);
+ YXLOG_API(Info) << "notifyEvent invoke completation." << YXLOGEnd;
+ });
}
//void FLTService::notifyEvent(const std::string& eventName,
@@ -60,6 +69,14 @@ void FLTService::notifyEventEx(const std::string& serviceName,
for (auto& it : logList) {
YXLOG_API(Info) << it << YXLOGEnd;
}
- NimCore::getInstance()->invokeMethod(eventName, arguments);
- YXLOG_API(Info) << "notifyEventEx invoke completation." << YXLOGEnd;
+
+ // Create shared pointers for the data to ensure copy constructibility
+ auto eventNameCopy = std::make_shared(eventName);
+ auto argsCopy = std::make_shared(arguments);
+
+ // Ensure we're on the platform thread
+ ThreadUtil::RunOnPlatformThread([eventNameCopy, argsCopy]() {
+ NimCore::getInstance()->invokeMethod(*eventNameCopy, *argsCopy);
+ YXLOG_API(Info) << "notifyEventEx invoke completation." << YXLOGEnd;
+ });
}
diff --git a/windows/src/common/ThreadUtil.cpp b/windows/src/common/ThreadUtil.cpp
new file mode 100644
index 0000000..1b7a61f
--- /dev/null
+++ b/windows/src/common/ThreadUtil.cpp
@@ -0,0 +1,89 @@
+#include "ThreadUtil.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace ThreadUtil {
+ // Global variables for thread management
+ static DWORD g_platformThreadId = 0;
+ static std::queue> g_taskQueue;
+ static std::mutex g_queueMutex;
+ static std::condition_variable g_queueCondition;
+ static bool g_initialized = false;
+ static HANDLE g_workerThread = NULL;
+
+ // Function to initialize the platform thread ID
+ void InitializePlatformThreadId() {
+ g_platformThreadId = GetCurrentThreadId();
+ g_initialized = true;
+ }
+
+ // Worker thread function
+ unsigned __stdcall WorkerThreadProc(void* param) {
+ while (true) {
+ std::function task;
+
+ {
+ std::unique_lock lock(g_queueMutex);
+ g_queueCondition.wait(lock, [] { return !g_taskQueue.empty(); });
+ task = g_taskQueue.front();
+ g_taskQueue.pop();
+ }
+
+ // Execute the task
+ task();
+ }
+
+ return 0;
+ }
+
+ // Function to ensure code runs on the platform thread
+ void RunOnPlatformThread(std::function callback) {
+ // Initialize on first call
+ if (!g_initialized) {
+ InitializePlatformThreadId();
+
+ // Create worker thread
+ g_workerThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, NULL, 0, NULL);
+ }
+
+ // If we're already on the platform thread, execute directly
+ if (GetCurrentThreadId() == g_platformThreadId) {
+ callback();
+ return;
+ }
+
+ // Create a shared_ptr to the callback to ensure it's copy constructible
+ auto callbackPtr = std::make_shared>(std::move(callback));
+
+ // Otherwise, queue the task for execution on the platform thread
+ {
+ std::lock_guard lock(g_queueMutex);
+ g_taskQueue.push([callbackPtr]() { (*callbackPtr)(); });
+ }
+ g_queueCondition.notify_one();
+ }
+
+ // Helper function to invoke method on platform thread
+ void InvokeMethodOnPlatformThread(
+ flutter::MethodChannel* channel,
+ const std::string& method,
+ std::unique_ptr arguments) {
+
+ if (!channel) return;
+
+ // Create shared pointers for the data to ensure copy constructibility
+ auto methodCopy = std::make_shared(method);
+ auto argsCopy = std::shared_ptr(arguments.release());
+
+ RunOnPlatformThread([channel, methodCopy, argsCopy]() {
+ channel->InvokeMethod(
+ *methodCopy,
+ std::make_unique(*argsCopy)
+ );
+ });
+ }
+}
diff --git a/windows/src/common/ThreadUtil.h b/windows/src/common/ThreadUtil.h
new file mode 100644
index 0000000..11e192a
--- /dev/null
+++ b/windows/src/common/ThreadUtil.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+
+namespace ThreadUtil {
+ // Function to initialize the platform thread ID
+ void InitializePlatformThreadId();
+
+ // Function to ensure code runs on the platform thread
+ void RunOnPlatformThread(std::function callback);
+
+ // Helper function to invoke method on platform thread
+ void InvokeMethodOnPlatformThread(
+ flutter::MethodChannel* channel,
+ const std::string& method,
+ std::unique_ptr arguments);
+}
diff --git a/windows/src/common/services/ChannelManager.cpp b/windows/src/common/services/ChannelManager.cpp
new file mode 100644
index 0000000..eeb6bad
--- /dev/null
+++ b/windows/src/common/services/ChannelManager.cpp
@@ -0,0 +1,201 @@
+#include "ChannelManager.h"
+#include
+#include "../NimResult.h"
+#include "../ZegoDataUtils.h"
+#include "ConstDefine.h"
+#include "Listen.h"
+
+ChannelManagerService::ChannelManagerService() {
+ m_serviceName = "channelManager";
+}
+
+void ChannelManagerService::onMethodCalled(
+ const std::string& method,
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (method == "setChannelListener") {
+ setChannelListener(arguments, result);
+ } else if (method == "getChannelMembersInfo") {
+ getChannelMembersInfo(arguments, result);
+ } else if (method == "getChannelMemberList") {
+ getChannelMemberList(arguments, result);
+ } else if (method == "getChannelsInfo") {
+ getChannelsInfo(arguments, result);
+ } else if (method == "joinChannel") {
+ joinChannel(arguments, result);
+ } else if (method == "quitChannel") {
+ quitChannel(arguments, result);
+ } else if (method == "changeChannelMute") {
+ changeChannelMute(arguments, result);
+ } else if (method == "changeChannelMemberMute") {
+ changeChannelMemberMute(arguments, result);
+ } else if (method == "isJoinChannel") {
+ isJoinChannel(arguments, result);
+ } else if (method == "getUsersInChannel") {
+ getUsersInChannel(arguments, result);
+ } else {
+ result->NotImplemented();
+ }
+}
+
+void ChannelManagerService::setChannelListener(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ set_channel_listener(NewChannelListenCallBack());
+ result->Success(flutter::EncodableValue());
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::getChannelMembersInfo(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelID_cs = const_cast(channelID.c_str());
+ char* userIDList_cs = const_cast(userIDList.c_str());
+
+ get_specified_channel_members_info(NewBaseCallBack(result), operationID_cs, channelID_cs, userIDList_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::getChannelMemberList(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ auto filter = zego_value_get_int(arguments->at(flutter::EncodableValue("filter")));
+ auto offset = zego_value_get_int(arguments->at(flutter::EncodableValue("offset")));
+ auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelID_cs = const_cast(channelID.c_str());
+
+ get_channel_member_list(NewBaseCallBack(result), operationID_cs, channelID_cs, filter, offset, count);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::getChannelsInfo(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("channelIDList")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelIDList_cs = const_cast(channelIDList.c_str());
+
+ get_specified_channels_info(NewBaseCallBack(result), operationID_cs, channelIDList_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::joinChannel(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ auto reason = zego_value_get_string(arguments->at(flutter::EncodableValue("reason")));
+ auto joinSource = zego_value_get_int(arguments->at(flutter::EncodableValue("joinSource")));
+ auto ex = zego_value_get_string(arguments->at(flutter::EncodableValue("ex")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelID_cs = const_cast(channelID.c_str());
+ char* reason_cs = const_cast(reason.c_str());
+ char* ex_cs = const_cast(ex.c_str());
+
+ join_channel(NewBaseCallBack(result), operationID_cs, channelID_cs, reason_cs, joinSource, ex_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::quitChannel(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelID_cs = const_cast(channelID.c_str());
+
+ quit_channel(NewBaseCallBack(result), operationID_cs, channelID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::changeChannelMute(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ // if (arguments) {
+ // auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ // auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ // auto mute = zego_value_get_bool(arguments->at(flutter::EncodableValue("mute")));
+ // char* operationID_cs = const_cast(operationID.c_str());
+ // char* channelID_cs = const_cast(channelID.c_str());
+
+ // change_channel_mute(NewBaseCallBack(result), operationID_cs, channelID_cs, mute);
+ // } else {
+ // result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ // }
+}
+
+void ChannelManagerService::changeChannelMemberMute(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ // if (arguments) {
+ // auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ // auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ // auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
+ // auto seconds = zego_value_get_int(arguments->at(flutter::EncodableValue("seconds")));
+ // char* operationID_cs = const_cast(operationID.c_str());
+ // char* channelID_cs = const_cast(channelID.c_str());
+ // char* userID_cs = const_cast(userID.c_str());
+
+ // change_channel_member_mute(NewBaseCallBack(result), operationID_cs, channelID_cs, userID_cs, seconds);
+ // } else {
+ // result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ // }
+}
+
+void ChannelManagerService::isJoinChannel(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelID_cs = const_cast(channelID.c_str());
+
+ is_join_channel(NewBaseCallBack(result), operationID_cs, channelID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ChannelManagerService::getUsersInChannel(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID")));
+ auto userIDs = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDs")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* channelID_cs = const_cast(channelID.c_str());
+ char* userIDs_cs = const_cast(userIDs.c_str());
+
+ get_users_in_channel(NewBaseCallBack(result), operationID_cs, channelID_cs, userIDs_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
\ No newline at end of file
diff --git a/windows/src/common/services/ChannelManager.h b/windows/src/common/services/ChannelManager.h
new file mode 100644
index 0000000..834f45e
--- /dev/null
+++ b/windows/src/common/services/ChannelManager.h
@@ -0,0 +1,56 @@
+#ifndef CHANNEL_MANAGER_SERVICE_H
+#define CHANNEL_MANAGER_SERVICE_H
+#include "../FLTService.h"
+#include "Listen.h"
+#include
+#include
+#include
+
+class ChannelManagerService : public FLTService
+{
+
+ public:
+ ChannelManagerService();
+
+ void onMethodCalled(
+ const std::string &method,
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+
+ // Method handlers
+ void setChannelListener(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getChannelMembersInfo(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getChannelMemberList(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getChannelsInfo(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void joinChannel(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void quitChannel(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void changeChannelMute(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void changeChannelMemberMute(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void isJoinChannel(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getUsersInChannel(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+
+ private:
+ std::string m_serviceName;
+ };
+
+#endif // CHANNEL_MANAGER_SERVICE_H
\ No newline at end of file
diff --git a/windows/src/common/services/ConstDefine.h b/windows/src/common/services/ConstDefine.h
index e3663f7..8d3f972 100644
--- a/windows/src/common/services/ConstDefine.h
+++ b/windows/src/common/services/ConstDefine.h
@@ -45,10 +45,14 @@ enum class ConstDefine {
MSG_DELETED,
RECV_NEW_MESSAGES,
RECV_OFFLINE_NEW_MESSAGES,
+
SELF_INFO_UPDATED,
USER_STATUS_CHANGED,
+
RECV_CUSTOM_BUSINESS_MESSAGE,
+
MESSAGE_KV_INFO_CHANGED,
+
OPEN,
PART_SIZE,
HASH_PART_PROGRESS,
@@ -59,9 +63,22 @@ enum class ConstDefine {
COMPLETE,
CONVERSATION_USER_INPUT_STATUS_CHANGED,
RECV_ONLINE_ONLY_MESSAGE,
- RECV_MESSAGE_EDIT,
+ NEW_RECV_MESSAGE_EDIT,
+
USER_TOKEN_INVALID,
- ON_PROGRESS
+
+ ON_PROGRESS,
+ JOINED_CHANNEL_ADDED,
+ JOINED_CHANNEL_DELETED,
+ CHANNEL_MEMBER_ADDED,
+ CHANNEL_MEMBER_DELETED,
+ CHANNEL_APPLICATION_ADDED,
+ CHANNEL_APPLICATION_DELETED,
+ CHANNEL_INFO_CHANGED,
+ CHANNEL_DISMISSED,
+ CHANNEL_MEMBER_INFO_CHANGED,
+ CHANNEL_APPLICATION_ACCEPTED,
+ CHANNEL_APPLICATION_REJECTED,
};
diff --git a/windows/src/common/services/ConversationManager.cpp b/windows/src/common/services/ConversationManager.cpp
new file mode 100644
index 0000000..d6ad3f8
--- /dev/null
+++ b/windows/src/common/services/ConversationManager.cpp
@@ -0,0 +1,341 @@
+#include "ConversationManager.h"
+#include
+#include "../NimResult.h"
+#include "../ZegoDataUtils.h"
+#include "ConstDefine.h"
+#include "Listen.h"
+
+ConversationManagerService::ConversationManagerService() {
+ m_serviceName = "conversationManager";
+}
+
+void ConversationManagerService::onMethodCalled(
+ const std::string& method,
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (method == "setConversationListener") {
+ setConversationListener(arguments, result);
+ } else if (method == "getAllConversationList") {
+ getAllConversationList(arguments, result);
+ } else if (method == "getConversationListSplit") {
+ getConversationListSplit(arguments, result);
+ } else if (method == "getOneConversation") {
+ getOneConversation(arguments, result);
+ } else if (method == "getMultipleConversation") {
+ getMultipleConversation(arguments, result);
+ } else if (method == "setConversationDraft") {
+ setConversationDraft(arguments, result);
+ } else if (method == "hideConversation") {
+ hideConversation(arguments, result);
+ } else if (method == "markConversationMessageAsRead") {
+ markConversationMessageAsRead(arguments, result);
+ } else if (method == "getTotalUnreadMsgCount") {
+ getTotalUnreadMsgCount(arguments, result);
+ } else if (method == "getConversationIDBySessionType") {
+ getConversationIDBySessionType(arguments, result);
+ } else if (method == "clearConversationAndDeleteAllMsg") {
+ clearConversationAndDeleteAllMsg(arguments, result);
+ } else if (method == "deleteConversationAndDeleteAllMsg") {
+ deleteConversationAndDeleteAllMsg(arguments, result);
+ } else if (method == "getAtAllTag") {
+ getAtAllTag(arguments, result);
+ } else if (method == "hideAllConversations") {
+ hideAllConversations(arguments, result);
+ } else if (method == "searchConversation") {
+ searchConversation(arguments, result);
+ } else if (method == "changeInputStates") {
+ changeInputStates(arguments, result);
+ } else if (method == "getInputStates") {
+ getInputStates(arguments, result);
+ } else if (method == "setConversation") {
+ setConversation(arguments, result);
+ } else if (method == "searchConversations") {
+ searchConversations(arguments, result);
+ } else {
+ result->NotImplemented();
+ }
+}
+
+void ConversationManagerService::setConversationListener(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ set_conversation_listener(NewConversationListenerCallBack());
+ result->Success(flutter::EncodableValue());
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getAllConversationList(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+
+ get_all_conversation_list(NewBaseCallBack(result), operationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getConversationListSplit(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto offset = zego_value_get_int(arguments->at(flutter::EncodableValue("offset")));
+ auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count")));
+ char* operationID_cs = const_cast(operationID.c_str());
+
+ get_conversation_list_split(NewBaseCallBack(result), operationID_cs, offset, count);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getOneConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto sessionType = zego_value_get_int(arguments->at(flutter::EncodableValue("sessionType")));
+ auto sourceID = zego_value_get_string(arguments->at(flutter::EncodableValue("sourceID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* sourceID_cs = const_cast(sourceID.c_str());
+
+ get_one_conversation(NewBaseCallBack(result), operationID_cs, sessionType, sourceID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getMultipleConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationIDList")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationIDList_cs = const_cast(conversationIDList.c_str());
+
+ get_multiple_conversation(NewBaseCallBack(result), operationID_cs, conversationIDList_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::setConversationDraft(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ auto draftText = zego_value_get_string(arguments->at(flutter::EncodableValue("draftText")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+ char* draftText_cs = const_cast(draftText.c_str());
+
+ set_conversation_draft(NewBaseCallBack(result), operationID_cs, conversationID_cs, draftText_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::hideConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+
+ hide_conversation(NewBaseCallBack(result), operationID_cs, conversationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::markConversationMessageAsRead(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+
+ mark_conversation_message_as_read(NewBaseCallBack(result), operationID_cs, conversationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getTotalUnreadMsgCount(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+
+ get_total_unread_msg_count(NewBaseCallBack(result), operationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getConversationIDBySessionType(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto sourceID = zego_value_get_string(arguments->at(flutter::EncodableValue("sourceID")));
+ auto sessionType = zego_value_get_int(arguments->at(flutter::EncodableValue("sessionType")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* sourceID_cs = const_cast(sourceID.c_str());
+
+ std::string conversationID = get_conversation_id_by_session_type(operationID_cs, sourceID_cs, sessionType);
+ result->Success(flutter::EncodableValue(conversationID));
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::clearConversationAndDeleteAllMsg(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+
+ clear_conversation_and_delete_all_msg(NewBaseCallBack(result), operationID_cs, conversationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::deleteConversationAndDeleteAllMsg(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+
+ delete_conversation_and_delete_all_msg(NewBaseCallBack(result), operationID_cs, conversationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getAtAllTag(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+
+ std::string tag = get_at_all_tag(operationID_cs);
+ result->Success(flutter::EncodableValue(tag));
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::hideAllConversations(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+
+ hide_all_conversations(NewBaseCallBack(result), operationID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::searchConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto name = zego_value_get_string(arguments->at(flutter::EncodableValue("name")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* name_cs = const_cast(name.c_str());
+
+ search_conversation(NewBaseCallBack(result), operationID_cs, name_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::changeInputStates(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ auto focus = zego_value_get_bool(arguments->at(flutter::EncodableValue("focus")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+
+ change_input_states(NewBaseCallBack(result), operationID_cs, conversationID_cs, focus);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::getInputStates(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+ char* userID_cs = const_cast(userID.c_str());
+
+ get_input_states(NewBaseCallBack(result), operationID_cs, conversationID_cs, userID_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::setConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto conversationID = zego_value_get_string(arguments->at(flutter::EncodableValue("conversationID")));
+ auto req = zego_value_get_string(arguments->at(flutter::EncodableValue("req")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* conversationID_cs = const_cast(conversationID.c_str());
+ char* req_cs = const_cast(req.c_str());
+
+ set_conversation(NewBaseCallBack(result), operationID_cs, conversationID_cs, req_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void ConversationManagerService::searchConversations(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto name = zego_value_get_string(arguments->at(flutter::EncodableValue("name")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* name_cs = const_cast(name.c_str());
+
+ search_conversations(NewBaseCallBack(result), operationID_cs, name_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
\ No newline at end of file
diff --git a/windows/src/common/services/ConversationManager.h b/windows/src/common/services/ConversationManager.h
new file mode 100644
index 0000000..8eaaff7
--- /dev/null
+++ b/windows/src/common/services/ConversationManager.h
@@ -0,0 +1,82 @@
+#ifndef CONVERSATION_MANAGER_SERVICE_H
+#define CONVERSATION_MANAGER_SERVICE_H
+#include "../FLTService.h"
+#include "Listen.h"
+#include
+#include
+#include
+
+class ConversationManagerService: public FLTService {
+public:
+ ConversationManagerService();
+
+
+ void onMethodCalled(
+ const std::string& method,
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+
+ // Method handlers
+ void setConversationListener(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getAllConversationList(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getConversationListSplit(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getOneConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getMultipleConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void setConversationDraft(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void hideConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void markConversationMessageAsRead(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getTotalUnreadMsgCount(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getConversationIDBySessionType(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void clearConversationAndDeleteAllMsg(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void deleteConversationAndDeleteAllMsg(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getAtAllTag(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void hideAllConversations(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void searchConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void changeInputStates(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void getInputStates(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void setConversation(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+ void searchConversations(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result);
+
+private:
+ std::string m_serviceName;
+};
+
+#endif // CONVERSATION_MANAGER_SERVICE_H
\ No newline at end of file
diff --git a/windows/src/common/services/FriendManager.cpp b/windows/src/common/services/FriendManager.cpp
new file mode 100644
index 0000000..2bb07ee
--- /dev/null
+++ b/windows/src/common/services/FriendManager.cpp
@@ -0,0 +1,383 @@
+#include "FriendManager.h"
+#include
+#include "../NimResult.h"
+#include "../ZegoDataUtils.h"
+#include "ConstDefine.h"
+#include "Listen.h"
+
+FriendshipManagerService::FriendshipManagerService()
+{
+ m_serviceName = "friendshipManager";
+}
+
+void FriendshipManagerService::onMethodCalled(
+ const std::string &method,
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (method == "setFriendListener")
+ {
+ setFriendListener(arguments, result);
+ }
+ else if (method == "getFriendsInfo")
+ {
+ getFriendsInfo(arguments, result);
+ }
+ else if (method == "addFriend")
+ {
+ addFriend(arguments, result);
+ }
+ else if (method == "getFriendApplicationListAsRecipient")
+ {
+ getFriendApplicationListAsRecipient(arguments, result);
+ }
+ else if (method == "getFriendApplicationListAsApplicant")
+ {
+ getFriendApplicationListAsApplicant(arguments, result);
+ }
+ else if (method == "getFriendList")
+ {
+ getFriendList(arguments, result);
+ }
+ else if (method == "getFriendListPage")
+ {
+ getFriendListPage(arguments, result);
+ }
+ else if (method == "addBlacklist")
+ {
+ addBlacklist(arguments, result);
+ }
+ else if (method == "getBlacklist")
+ {
+ getBlacklist(arguments, result);
+ }
+ else if (method == "removeBlacklist")
+ {
+ removeBlacklist(arguments, result);
+ }
+ else if (method == "checkFriend")
+ {
+ checkFriend(arguments, result);
+ }
+ else if (method == "deleteFriend")
+ {
+ deleteFriend(arguments, result);
+ }
+ else if (method == "acceptFriendApplication")
+ {
+ acceptFriendApplication(arguments, result);
+ }
+ else if (method == "refuseFriendApplication")
+ {
+ refuseFriendApplication(arguments, result);
+ }
+ else if (method == "searchFriends")
+ {
+ searchFriends(arguments, result);
+ }
+ else if (method == "updateFriends")
+ {
+ updateFriends(arguments, result);
+ }
+ else
+ {
+ result->NotImplemented();
+ }
+}
+
+void FriendshipManagerService::setFriendListener(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ set_friend_listener(NewFriendshipListenCallBack());
+ result->Success(flutter::EncodableValue());
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::getFriendsInfo(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
+ auto filterBlack = zego_value_get_bool(arguments->at(flutter::EncodableValue("filterBlack")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *userIDList_cs = const_cast(userIDList.c_str());
+
+ get_specified_friends_info(NewBaseCallBack(result), operationID_cs, userIDList_cs, filterBlack);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::addFriend(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto friendInfo = map_2_json(*arguments);
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *friendInfo_cs = const_cast(friendInfo.c_str());
+
+ add_friend(NewBaseCallBack(result), operationID_cs, friendInfo_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::getFriendApplicationListAsRecipient(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char *operationID_cs = const_cast(operationID.c_str());
+
+ get_friend_application_list_as_recipient(NewBaseCallBack(result), operationID_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::getFriendApplicationListAsApplicant(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char *operationID_cs = const_cast(operationID.c_str());
+
+ get_friend_application_list_as_applicant(NewBaseCallBack(result), operationID_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::getFriendList(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto filterBlack = zego_value_get_bool(arguments->at(flutter::EncodableValue("filterBlack")));
+ char *operationID_cs = const_cast(operationID.c_str());
+
+ get_friend_list(NewBaseCallBack(result), operationID_cs, filterBlack);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::getFriendListPage(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto offset = zego_value_get_int(arguments->at(flutter::EncodableValue("offset")));
+ auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count")));
+ auto filterBlack = zego_value_get_bool(arguments->at(flutter::EncodableValue("filterBlack")));
+ char *operationID_cs = const_cast(operationID.c_str());
+
+ get_friend_list_page(NewBaseCallBack(result), operationID_cs, offset, count, filterBlack);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::addBlacklist(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
+ auto ex = zego_value_get_string(arguments->at(flutter::EncodableValue("ex")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *userID_cs = const_cast(userID.c_str());
+ char *ex_cs = const_cast(ex.c_str());
+
+ add_black(NewBaseCallBack(result), operationID_cs, userID_cs, ex_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::getBlacklist(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ char *operationID_cs = const_cast(operationID.c_str());
+
+ get_black_list(NewBaseCallBack(result), operationID_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::removeBlacklist(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *userID_cs = const_cast(userID.c_str());
+
+ remove_black(NewBaseCallBack(result), operationID_cs, userID_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::checkFriend(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *userIDList_cs = const_cast(userIDList.c_str());
+
+ check_friend(NewBaseCallBack(result), operationID_cs, userIDList_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::deleteFriend(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *userID_cs = const_cast(userID.c_str());
+
+ delete_friend(NewBaseCallBack(result), operationID_cs, userID_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::acceptFriendApplication(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto applicationInfo = map_2_json(*arguments);
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *applicationInfo_cs = const_cast(applicationInfo.c_str());
+
+ accept_friend_application(NewBaseCallBack(result), operationID_cs, applicationInfo_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::refuseFriendApplication(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto applicationInfo = map_2_json(*arguments);
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *applicationInfo_cs = const_cast(applicationInfo.c_str());
+
+ refuse_friend_application(NewBaseCallBack(result), operationID_cs, applicationInfo_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::searchFriends(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto searchParam = zego_value_get_string(arguments->at(flutter::EncodableValue("searchParam")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *searchParam_cs = const_cast(searchParam.c_str());
+
+ search_friends(NewBaseCallBack(result), operationID_cs, searchParam_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void FriendshipManagerService::updateFriends(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result)
+{
+ if (arguments)
+ {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto req = zego_value_get_string(arguments->at(flutter::EncodableValue("req")));
+ char *operationID_cs = const_cast(operationID.c_str());
+ char *req_cs = const_cast(req.c_str());
+
+ update_friends(NewBaseCallBack(result), operationID_cs, req_cs);
+ }
+ else
+ {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
\ No newline at end of file
diff --git a/windows/src/common/services/FriendManager.h b/windows/src/common/services/FriendManager.h
new file mode 100644
index 0000000..0ebaaa5
--- /dev/null
+++ b/windows/src/common/services/FriendManager.h
@@ -0,0 +1,74 @@
+#ifndef FRIENDSHIP_MANAGER_SERVICE_H
+#define FRIENDSHIP_MANAGER_SERVICE_H
+
+#include "../FLTService.h"
+#include "Listen.h"
+#include
+#include
+#include
+
+class FriendshipManagerService : public FLTService
+{
+public:
+ FriendshipManagerService();
+
+ void onMethodCalled(
+ const std::string &method,
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+
+ // Method handlers
+ void setFriendListener(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getFriendsInfo(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void addFriend(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getFriendApplicationListAsRecipient(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getFriendApplicationListAsApplicant(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getFriendList(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getFriendListPage(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void addBlacklist(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void getBlacklist(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void removeBlacklist(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void checkFriend(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void deleteFriend(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void acceptFriendApplication(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void refuseFriendApplication(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void searchFriends(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+ void updateFriends(
+ const flutter::EncodableMap *arguments,
+ std::shared_ptr> result);
+
+private:
+ std::string m_serviceName;
+};
+
+#endif // FRIENDSHIP_MANAGER_SERVICE_H
\ No newline at end of file
diff --git a/windows/src/common/services/GroupManager.cpp b/windows/src/common/services/GroupManager.cpp
new file mode 100644
index 0000000..f5e1f3c
--- /dev/null
+++ b/windows/src/common/services/GroupManager.cpp
@@ -0,0 +1,508 @@
+#include "GroupManager.h"
+#include
+#include "../NimResult.h"
+#include "../ZegoDataUtils.h"
+#include "ConstDefine.h"
+#include "Listen.h"
+
+GroupManagerService::GroupManagerService() {
+ m_serviceName = "groupManager";
+}
+
+void GroupManagerService::onMethodCalled(
+ const std::string& method,
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (method == "setGroupListener") {
+ setGroupListener(arguments, result);
+ } else if (method == "inviteUserToGroup") {
+ inviteUserToGroup(arguments, result);
+ } else if (method == "kickGroupMember") {
+ kickGroupMember(arguments, result);
+ } else if (method == "getGroupMembersInfo") {
+ getGroupMembersInfo(arguments, result);
+ } else if (method == "getGroupMemberList") {
+ getGroupMemberList(arguments, result);
+ } else if (method == "getJoinedGroupList") {
+ getJoinedGroupList(arguments, result);
+ } else if (method == "getJoinedGroupListPage") {
+ getJoinedGroupListPage(arguments, result);
+ } else if (method == "createGroup") {
+ createGroup(arguments, result);
+ } else if (method == "setGroupInfo") {
+ setGroupInfo(arguments, result);
+ } else if (method == "getGroupsInfo") {
+ getGroupsInfo(arguments, result);
+ } else if (method == "joinGroup") {
+ joinGroup(arguments, result);
+ } else if (method == "quitGroup") {
+ quitGroup(arguments, result);
+ } else if (method == "transferGroupOwner") {
+ transferGroupOwner(arguments, result);
+ } else if (method == "getGroupApplicationListAsRecipient") {
+ getGroupApplicationListAsRecipient(arguments, result);
+ } else if (method == "getGroupApplicationListAsApplicant") {
+ getGroupApplicationListAsApplicant(arguments, result);
+ } else if (method == "acceptGroupApplication") {
+ acceptGroupApplication(arguments, result);
+ } else if (method == "refuseGroupApplication") {
+ refuseGroupApplication(arguments, result);
+ } else if (method == "dismissGroup") {
+ dismissGroup(arguments, result);
+ } else if (method == "changeGroupMute") {
+ changeGroupMute(arguments, result);
+ } else if (method == "changeGroupMemberMute") {
+ changeGroupMemberMute(arguments, result);
+ } else if (method == "searchGroups") {
+ searchGroups(arguments, result);
+ } else if (method == "getGroupMemberListByJoinTimeFilter") {
+ getGroupMemberListByJoinTimeFilter(arguments, result);
+ } else if (method == "getGroupMemberOwnerAndAdmin") {
+ getGroupMemberOwnerAndAdmin(arguments, result);
+ } else if (method == "searchGroupMembers") {
+ searchGroupMembers(arguments, result);
+ } else if (method == "setGroupMemberInfo") {
+ setGroupMemberInfo(arguments, result);
+ } else if (method == "isJoinGroup") {
+ isJoinGroup(arguments, result);
+ } else if (method == "getUsersInGroup") {
+ getUsersInGroup(arguments, result);
+ } else {
+ result->NotImplemented();
+ }
+}
+
+void GroupManagerService::setGroupListener(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ set_group_listener(NewGroupListenerCallBack());
+ result->Success(flutter::EncodableValue());
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void GroupManagerService::inviteUserToGroup(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto groupID = zego_value_get_string(arguments->at(flutter::EncodableValue("groupID")));
+ auto reason = zego_value_get_string(arguments->at(flutter::EncodableValue("reason")));
+ auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* groupID_cs = const_cast(groupID.c_str());
+ char* reason_cs = const_cast(reason.c_str());
+ char* userIDList_cs = const_cast(userIDList.c_str());
+
+ invite_user_to_group(NewBaseCallBack(result), operationID_cs, groupID_cs, reason_cs, userIDList_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void GroupManagerService::kickGroupMember(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto groupID = zego_value_get_string(arguments->at(flutter::EncodableValue("groupID")));
+ auto reason = zego_value_get_string(arguments->at(flutter::EncodableValue("reason")));
+ auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* groupID_cs = const_cast(groupID.c_str());
+ char* reason_cs = const_cast(reason.c_str());
+ char* userIDList_cs = const_cast(userIDList.c_str());
+
+ kick_group_member(NewBaseCallBack(result), operationID_cs, groupID_cs, reason_cs, userIDList_cs);
+ } else {
+ result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
+ }
+}
+
+void GroupManagerService::getGroupMembersInfo(
+ const flutter::EncodableMap* arguments,
+ std::shared_ptr> result) {
+ if (arguments) {
+ auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID")));
+ auto groupID = zego_value_get_string(arguments->at(flutter::EncodableValue("groupID")));
+ auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList")));
+ char* operationID_cs = const_cast(operationID.c_str());
+ char* groupID_cs = const_cast(groupID.c_str());
+ char* userIDList_cs = const_cast