parent
43515d8058
commit
67bf71c998
Binary file not shown.
@ -0,0 +1,89 @@ |
|||||||
|
#include "ThreadUtil.h" |
||||||
|
#include <windows.h> |
||||||
|
#include <process.h> |
||||||
|
#include <queue> |
||||||
|
#include <mutex> |
||||||
|
#include <condition_variable> |
||||||
|
#include <memory> |
||||||
|
|
||||||
|
namespace ThreadUtil { |
||||||
|
// Global variables for thread management
|
||||||
|
static DWORD g_platformThreadId = 0; |
||||||
|
static std::queue<std::function<void()>> 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<void()> task; |
||||||
|
|
||||||
|
{ |
||||||
|
std::unique_lock<std::mutex> 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<void()> 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::function<void()>>(std::move(callback)); |
||||||
|
|
||||||
|
// Otherwise, queue the task for execution on the platform thread
|
||||||
|
{ |
||||||
|
std::lock_guard<std::mutex> lock(g_queueMutex); |
||||||
|
g_taskQueue.push([callbackPtr]() { (*callbackPtr)(); }); |
||||||
|
} |
||||||
|
g_queueCondition.notify_one(); |
||||||
|
} |
||||||
|
|
||||||
|
// Helper function to invoke method on platform thread
|
||||||
|
void InvokeMethodOnPlatformThread( |
||||||
|
flutter::MethodChannel<flutter::EncodableValue>* channel, |
||||||
|
const std::string& method, |
||||||
|
std::unique_ptr<flutter::EncodableValue> arguments) { |
||||||
|
|
||||||
|
if (!channel) return; |
||||||
|
|
||||||
|
// Create shared pointers for the data to ensure copy constructibility
|
||||||
|
auto methodCopy = std::make_shared<std::string>(method); |
||||||
|
auto argsCopy = std::shared_ptr<flutter::EncodableValue>(arguments.release()); |
||||||
|
|
||||||
|
RunOnPlatformThread([channel, methodCopy, argsCopy]() { |
||||||
|
channel->InvokeMethod( |
||||||
|
*methodCopy, |
||||||
|
std::make_unique<flutter::EncodableValue>(*argsCopy) |
||||||
|
); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <functional> |
||||||
|
#include <windows.h> |
||||||
|
#include <flutter/method_channel.h> |
||||||
|
#include <flutter/encodable_value.h> |
||||||
|
|
||||||
|
namespace ThreadUtil { |
||||||
|
// Function to initialize the platform thread ID
|
||||||
|
void InitializePlatformThreadId(); |
||||||
|
|
||||||
|
// Function to ensure code runs on the platform thread
|
||||||
|
void RunOnPlatformThread(std::function<void()> callback); |
||||||
|
|
||||||
|
// Helper function to invoke method on platform thread
|
||||||
|
void InvokeMethodOnPlatformThread( |
||||||
|
flutter::MethodChannel<flutter::EncodableValue>* channel, |
||||||
|
const std::string& method, |
||||||
|
std::unique_ptr<flutter::EncodableValue> arguments); |
||||||
|
} |
@ -0,0 +1,201 @@ |
|||||||
|
#include "ChannelManager.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
#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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(channelID.c_str()); |
||||||
|
char* userIDList_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelIDList_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(channelID.c_str()); |
||||||
|
char* reason_cs = const_cast<char*>(reason.c_str()); |
||||||
|
char* ex_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str());
|
||||||
|
// char* channelID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str());
|
||||||
|
// char* channelID_cs = const_cast<char*>(channelID.c_str());
|
||||||
|
// char* userID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(channelID.c_str()); |
||||||
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str()); |
||||||
|
|
||||||
|
get_users_in_channel(NewBaseCallBack(result), operationID_cs, channelID_cs, userIDs_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
#ifndef CHANNEL_MANAGER_SERVICE_H |
||||||
|
#define CHANNEL_MANAGER_SERVICE_H |
||||||
|
#include "../FLTService.h" |
||||||
|
#include "Listen.h" |
||||||
|
#include <flutter/standard_method_codec.h> |
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
class ChannelManagerService : public FLTService |
||||||
|
{ |
||||||
|
|
||||||
|
public: |
||||||
|
ChannelManagerService(); |
||||||
|
|
||||||
|
void onMethodCalled( |
||||||
|
const std::string &method, |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
// Method handlers
|
||||||
|
void setChannelListener( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getChannelMembersInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getChannelMemberList( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getChannelsInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void joinChannel( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void quitChannel( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void changeChannelMute( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void changeChannelMemberMute( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void isJoinChannel( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getUsersInChannel( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
private: |
||||||
|
std::string m_serviceName; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // CHANNEL_MANAGER_SERVICE_H
|
@ -0,0 +1,341 @@ |
|||||||
|
#include "ConversationManager.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
#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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* sourceID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationIDList_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* draftText_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* sourceID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* name_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* req_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* name_cs = const_cast<char*>(name.c_str()); |
||||||
|
|
||||||
|
search_conversations(NewBaseCallBack(result), operationID_cs, name_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,82 @@ |
|||||||
|
#ifndef CONVERSATION_MANAGER_SERVICE_H |
||||||
|
#define CONVERSATION_MANAGER_SERVICE_H |
||||||
|
#include "../FLTService.h" |
||||||
|
#include "Listen.h" |
||||||
|
#include <flutter/standard_method_codec.h> |
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
class ConversationManagerService: public FLTService { |
||||||
|
public: |
||||||
|
ConversationManagerService(); |
||||||
|
|
||||||
|
|
||||||
|
void onMethodCalled( |
||||||
|
const std::string& method, |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
// Method handlers
|
||||||
|
void setConversationListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getAllConversationList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getConversationListSplit( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getOneConversation( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getMultipleConversation( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setConversationDraft( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void hideConversation( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void markConversationMessageAsRead( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getTotalUnreadMsgCount( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getConversationIDBySessionType( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void clearConversationAndDeleteAllMsg( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void deleteConversationAndDeleteAllMsg( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getAtAllTag( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void hideAllConversations( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void searchConversation( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void changeInputStates( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getInputStates( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setConversation( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void searchConversations( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
private: |
||||||
|
std::string m_serviceName; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // CONVERSATION_MANAGER_SERVICE_H
|
@ -0,0 +1,383 @@ |
|||||||
|
#include "FriendManager.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
#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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *userIDList_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *friendInfo_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> result) |
||||||
|
{ |
||||||
|
if (arguments) |
||||||
|
{ |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char *operationID_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> result) |
||||||
|
{ |
||||||
|
if (arguments) |
||||||
|
{ |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char *operationID_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *userID_cs = const_cast<char *>(userID.c_str()); |
||||||
|
char *ex_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> result) |
||||||
|
{ |
||||||
|
if (arguments) |
||||||
|
{ |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char *operationID_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *userID_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *userIDList_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *userID_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *applicationInfo_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *applicationInfo_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *searchParam_cs = const_cast<char *>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char *>(operationID.c_str()); |
||||||
|
char *req_cs = const_cast<char *>(req.c_str()); |
||||||
|
|
||||||
|
update_friends(NewBaseCallBack(result), operationID_cs, req_cs); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
#ifndef FRIENDSHIP_MANAGER_SERVICE_H |
||||||
|
#define FRIENDSHIP_MANAGER_SERVICE_H |
||||||
|
|
||||||
|
#include "../FLTService.h" |
||||||
|
#include "Listen.h" |
||||||
|
#include <flutter/standard_method_codec.h> |
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
class FriendshipManagerService : public FLTService |
||||||
|
{ |
||||||
|
public: |
||||||
|
FriendshipManagerService(); |
||||||
|
|
||||||
|
void onMethodCalled( |
||||||
|
const std::string &method, |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
// Method handlers
|
||||||
|
void setFriendListener( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getFriendsInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void addFriend( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getFriendApplicationListAsRecipient( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getFriendApplicationListAsApplicant( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getFriendList( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getFriendListPage( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void addBlacklist( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getBlacklist( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void removeBlacklist( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void checkFriend( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void deleteFriend( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void acceptFriendApplication( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void refuseFriendApplication( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void searchFriends( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void updateFriends( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
private: |
||||||
|
std::string m_serviceName; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // FRIENDSHIP_MANAGER_SERVICE_H
|
@ -0,0 +1,508 @@ |
|||||||
|
#include "GroupManager.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
#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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* reason_cs = const_cast<char*>(reason.c_str()); |
||||||
|
char* userIDList_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* reason_cs = const_cast<char*>(reason.c_str()); |
||||||
|
char* userIDList_cs = const_cast<char*>(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<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* userIDList_cs = const_cast<char*>(userIDList.c_str()); |
||||||
|
|
||||||
|
get_specified_group_members_info(NewBaseCallBack(result), operationID_cs, groupID_cs, userIDList_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getGroupMemberList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 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<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
|
||||||
|
get_group_member_list(NewBaseCallBack(result), operationID_cs, groupID_cs, filter, offset, count); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getJoinedGroupList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
get_joined_group_list(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getJoinedGroupListPage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
get_joined_group_list_page(NewBaseCallBack(result), operationID_cs, offset, count); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::createGroup( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto groupInfo = map_2_json(*arguments); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupInfo_cs = const_cast<char*>(groupInfo.c_str()); |
||||||
|
|
||||||
|
create_group(NewBaseCallBack(result), operationID_cs, groupInfo_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::setGroupInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto groupInfo = zego_value_get_string(arguments->at(flutter::EncodableValue("groupInfo"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupInfo_cs = const_cast<char*>(groupInfo.c_str()); |
||||||
|
|
||||||
|
set_group_info(NewBaseCallBack(result), operationID_cs, groupInfo_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getGroupsInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto groupIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("groupIDList"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupIDList_cs = const_cast<char*>(groupIDList.c_str()); |
||||||
|
|
||||||
|
get_specified_groups_info(NewBaseCallBack(result), operationID_cs, groupIDList_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::joinGroup( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 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<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* reason_cs = const_cast<char*>(reason.c_str()); |
||||||
|
char* ex_cs = const_cast<char*>(ex.c_str()); |
||||||
|
|
||||||
|
join_group(NewBaseCallBack(result), operationID_cs, groupID_cs, reason_cs, joinSource, ex_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::quitGroup( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
|
||||||
|
quit_group(NewBaseCallBack(result), operationID_cs, groupID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::transferGroupOwner( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
|
||||||
|
transfer_group_owner(NewBaseCallBack(result), operationID_cs, groupID_cs, userID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getGroupApplicationListAsRecipient( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
get_group_application_list_as_recipient(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getGroupApplicationListAsApplicant( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
get_group_application_list_as_applicant(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::acceptGroupApplication( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID"))); |
||||||
|
auto handleMsg = zego_value_get_string(arguments->at(flutter::EncodableValue("handleMsg"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
char* handleMsg_cs = const_cast<char*>(handleMsg.c_str()); |
||||||
|
|
||||||
|
accept_group_application(NewBaseCallBack(result), operationID_cs, groupID_cs, userID_cs, handleMsg_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::refuseGroupApplication( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID"))); |
||||||
|
auto handleMsg = zego_value_get_string(arguments->at(flutter::EncodableValue("handleMsg"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
char* handleMsg_cs = const_cast<char*>(handleMsg.c_str()); |
||||||
|
|
||||||
|
refuse_group_application(NewBaseCallBack(result), operationID_cs, groupID_cs, userID_cs, handleMsg_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::dismissGroup( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
|
||||||
|
dismiss_group(NewBaseCallBack(result), operationID_cs, groupID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::changeGroupMute( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 mute = zego_value_get_bool(arguments->at(flutter::EncodableValue("mute"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
|
||||||
|
change_group_mute(NewBaseCallBack(result), operationID_cs, groupID_cs, mute); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::changeGroupMemberMute( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 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<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
|
||||||
|
change_group_member_mute(NewBaseCallBack(result), operationID_cs, groupID_cs, userID_cs, seconds); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::searchGroups( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* searchParam_cs = const_cast<char*>(searchParam.c_str()); |
||||||
|
|
||||||
|
search_groups(NewBaseCallBack(result), operationID_cs, searchParam_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getGroupMemberListByJoinTimeFilter( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 offset = zego_value_get_int(arguments->at(flutter::EncodableValue("offset"))); |
||||||
|
auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count"))); |
||||||
|
auto joinTimeBegin = zego_value_get_int(arguments->at(flutter::EncodableValue("joinTimeBegin"))); |
||||||
|
auto joinTimeEnd = zego_value_get_int(arguments->at(flutter::EncodableValue("joinTimeEnd"))); |
||||||
|
auto excludeUserIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("excludeUserIDList"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* excludeUserIDList_cs = const_cast<char*>(excludeUserIDList.c_str()); |
||||||
|
|
||||||
|
get_group_member_list_by_join_time_filter(NewBaseCallBack(result), operationID_cs, groupID_cs, offset, count, joinTimeBegin, joinTimeEnd, excludeUserIDList_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getGroupMemberOwnerAndAdmin( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
|
||||||
|
get_group_member_owner_and_admin(NewBaseCallBack(result), operationID_cs, groupID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::searchGroupMembers( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* searchParam_cs = const_cast<char*>(searchParam.c_str()); |
||||||
|
|
||||||
|
search_group_members(NewBaseCallBack(result), operationID_cs, searchParam_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::setGroupMemberInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto info = zego_value_get_string(arguments->at(flutter::EncodableValue("info"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* info_cs = const_cast<char*>(info.c_str()); |
||||||
|
|
||||||
|
set_group_member_info(NewBaseCallBack(result), operationID_cs, info_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::isJoinGroup( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
|
||||||
|
is_join_group(NewBaseCallBack(result), operationID_cs, groupID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void GroupManagerService::getUsersInGroup( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 userIDs = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDs"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str()); |
||||||
|
|
||||||
|
get_users_in_group(NewBaseCallBack(result), operationID_cs, groupID_cs, userIDs_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,107 @@ |
|||||||
|
#ifndef GROUP_MANAGER_SERVICE_H |
||||||
|
#define GROUP_MANAGER_SERVICE_H |
||||||
|
|
||||||
|
#include "../FLTService.h" |
||||||
|
#include "Listen.h" |
||||||
|
#include <flutter/standard_method_codec.h> |
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
class GroupManagerService : public FLTService |
||||||
|
{ |
||||||
|
public: |
||||||
|
GroupManagerService(); |
||||||
|
|
||||||
|
void onMethodCalled( |
||||||
|
const std::string &method, |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
// Method handlers
|
||||||
|
void setGroupListener( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void inviteUserToGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void kickGroupMember( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupMembersInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupMemberList( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getJoinedGroupList( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getJoinedGroupListPage( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setGroupInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupsInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void joinGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void quitGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void transferGroupOwner( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupApplicationListAsRecipient( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupApplicationListAsApplicant( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void acceptGroupApplication( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void refuseGroupApplication( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void dismissGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void changeGroupMute( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void changeGroupMemberMute( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void searchGroups( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupMemberListByJoinTimeFilter( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getGroupMemberOwnerAndAdmin( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void searchGroupMembers( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setGroupMemberInfo( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void isJoinGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getUsersInGroup( |
||||||
|
const flutter::EncodableMap *arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
private: |
||||||
|
std::string m_serviceName; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // GROUP_MANAGER_SERVICE_H
|
@ -1,20 +1,621 @@ |
|||||||
#include "Listen.h" |
#include "Listen.h" |
||||||
#include <unordered_map> |
|
||||||
|
|
||||||
std::unordered_map <std::string, std::unique_ptr<BaseCallBack>> g_baseCallBackMap; |
#include "wrapp_cpp_function.inc" |
||||||
std::mutex g_baseCallBackMapMutex; |
#include "ConstDefine.h" |
||||||
|
#include "../FLTService.h" |
||||||
|
#include "../ThreadUtil.h" |
||||||
|
#include "../json.hpp" |
||||||
|
using json = nlohmann::json; |
||||||
|
|
||||||
void NewBaseCallBack(std::string opid, |
CB_S_I_S_S NewBaseCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) |
||||||
std::shared_ptr <flutter::MethodResult<flutter::EncodableValue>> result) { |
{ |
||||||
std::lock_guard <std::mutex> lock(g_baseCallBackMapMutex); |
|
||||||
g_baseCallBackMap[opid] = std::make_unique<BaseCallBack>(result); |
auto t = std::make_shared<BaseCallBack>(result); |
||||||
|
auto f = [t](const std::string &operationID, int errCode, const std::string &errMsg, const std::string &data) |
||||||
|
{ |
||||||
|
t->HandleCallback(operationID, errCode, errMsg, data); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_callonce_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void InitListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::CONNECTING: |
||||||
|
arguments.insert(std::make_pair("type", "onConnecting")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CONNECT_SUCCESS: |
||||||
|
arguments.insert(std::make_pair("type", "onConnectSuccess")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CONNECT_FAILED: |
||||||
|
arguments.insert(std::make_pair("type", "onConnectFailed")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::KICKED_OFFLINE: |
||||||
|
arguments.insert(std::make_pair("type", "onKickedOffline")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::USER_TOKEN_EXPIRED: |
||||||
|
arguments.insert(std::make_pair("type", "onUserTokenExpired")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::USER_TOKEN_INVALID: |
||||||
|
arguments.insert(std::make_pair("type", "onUserTokenExpired")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("connectListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewInitListenCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<InitListenCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void UploadFileListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::OPEN: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("size", std::stoi(msg))); |
||||||
|
arguments.insert(std::make_pair("type", "open")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::PART_SIZE: |
||||||
|
// 需要使用json反序列化对象msg,使用临时结构
|
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("partSize", j.at("partSize").get<int>())); |
||||||
|
data.insert(std::make_pair("num", j.at("num").get<int>())); |
||||||
|
arguments.insert(std::make_pair("type", "partSize")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::HASH_PART_PROGRESS: |
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("index", j.at("index").get<int>())); |
||||||
|
data.insert(std::make_pair("size", j.at("size").get<int>())); |
||||||
|
data.insert(std::make_pair("partHash", j.at("partHash").get<std::string>())); |
||||||
|
arguments.insert(std::make_pair("type", "hashPartProgress")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::HASH_PART_COMPLETE: |
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("partHash", j.at("partHash").get<std::string>())); |
||||||
|
data.insert(std::make_pair("fileHash", j.at("fileHash").get<std::string>())); |
||||||
|
arguments.insert(std::make_pair("type", "hashPartComplete")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::UPLOAD_ID: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("uploadID", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "uploadID")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::UPLOAD_PART_COMPLETE: |
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("index", j.at("index").get<int>())); |
||||||
|
data.insert(std::make_pair("partSize", j.at("partSize").get<int>())); |
||||||
|
data.insert(std::make_pair("partHash", j.at("partHash").get<std::string>())); |
||||||
|
arguments.insert(std::make_pair("type", "uploadPartComplete")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::UPLOAD_COMPLETE: |
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("fileSize", j.at("fileSize").get<int>())); |
||||||
|
data.insert(std::make_pair("streamSize", j.at("streamSize").get<int>())); |
||||||
|
data.insert(std::make_pair("storageSize", j.at("storageSize").get<int>())); |
||||||
|
arguments.insert(std::make_pair("type", "uploadProgress")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::COMPLETE: |
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("size", j.at("fileSize").get<int>())); |
||||||
|
data.insert(std::make_pair("url", j.at("url").get<std::string>())); |
||||||
|
data.insert(std::make_pair("type", j.at("fileSize").get<int>())); |
||||||
|
arguments.insert(std::make_pair("type", "complete")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("uploadFileListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewUploadFileListenCallBack(std::string id) |
||||||
|
{ |
||||||
|
auto t = std::make_shared<UploadFileListenCallBack>(id); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void UploadLogsListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::ON_PROGRESS: |
||||||
|
j = json::parse(msg); |
||||||
|
data.insert(std::make_pair("current", j.at("current").get<int>())); |
||||||
|
data.insert(std::make_pair("size", j.at("size").get<int>())); |
||||||
|
arguments.insert(std::make_pair("type", "onProgress")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("uploadLogsListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewUploadLogsListenCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<UploadLogsListenCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
} |
} |
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void UserListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::SELF_INFO_UPDATED: |
||||||
|
|
||||||
void CallBaseCallBack(char *opid, int errCode, char *errMsg, char *msg) { |
arguments.insert(std::make_pair("type", "onSelfInfoUpdated")); |
||||||
std::lock_guard <std::mutex> lock(g_baseCallBackMapMutex); |
arguments.insert(std::make_pair("data", msg)); |
||||||
auto it = g_baseCallBackMap.find(std::string(opid)); |
break; |
||||||
if (it != g_baseCallBackMap.end()) { |
case ConstDefine::USER_STATUS_CHANGED: |
||||||
auto ctx = std::move(it->second); //unique_ptr
|
arguments.insert(std::make_pair("type", "onUserStatusChanged")); |
||||||
ctx->HandleCallback(opid, errCode, errMsg, msg); |
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
} |
} |
||||||
} |
notifyEvent("userListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewUserListenCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<UserListenCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void AdvancedMsgListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::MSG_DELETED: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("message", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onMsgDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::NEW_RECV_MESSAGE_REVOKED: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("messageRevoked", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onNewRecvMessageRevoked")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::NEW_RECV_MESSAGE_EDIT: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("messageEdited", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onNewRecvMessageEdited")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::RECV_C2C_READ_RECEIPT: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("msgReceiptList", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onRecvC2CReadReceipt")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::RECV_NEW_MESSAGE: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("message", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onRecvNewMessage")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::RECV_OFFLINE_NEW_MESSAGE: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("message", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onRecvOfflineNewMessage")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
case ConstDefine::RECV_ONLINE_ONLY_MESSAGE: |
||||||
|
data.insert(std::make_pair("id", id)); |
||||||
|
data.insert(std::make_pair("message", msg)); |
||||||
|
arguments.insert(std::make_pair("type", "onRecvOnlineOnlyMessage")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("advancedMsgListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewAdvancedMsgListenCallBack(std::string id) |
||||||
|
{ |
||||||
|
auto t = std::make_shared<AdvancedMsgListenCallBack>(id); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void MsgSendListenerCallBack::HandleCallback(const std::string &operationID, int state, const std::string &error, const std::string &msg, long progress) |
||||||
|
{ |
||||||
|
if (result == nullptr) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (state == 0 && progress == 0 && msg.empty()) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
data.insert(std::make_pair("clientMsgID", clientMsgID)); |
||||||
|
data.insert(std::make_pair("progress", progress)); |
||||||
|
arguments.insert(std::make_pair("type", "onProgress")); |
||||||
|
arguments.insert(std::make_pair("data", data)); |
||||||
|
notifyEvent("msgSendProgressListener", arguments); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
// Create shared pointers for the data to ensure copy constructibility
|
||||||
|
auto resultCopy = result; |
||||||
|
auto dataCopy = std::make_shared<std::string>(msg); |
||||||
|
auto errCodeCopy = state; |
||||||
|
auto errMsgCopy = std::make_shared<std::string>(error); |
||||||
|
|
||||||
|
// Ensure callback runs on the platform thread
|
||||||
|
ThreadUtil::RunOnPlatformThread([resultCopy, errCodeCopy, errMsgCopy, dataCopy]() |
||||||
|
{ |
||||||
|
if (errCodeCopy == 0) { |
||||||
|
resultCopy->Success(flutter::EncodableValue(*dataCopy)); |
||||||
|
} else { |
||||||
|
resultCopy->Error(std::to_string(errCodeCopy), *errMsgCopy, |
||||||
|
flutter::EncodableValue(*dataCopy)); |
||||||
|
} }); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
CB_S_I_S_S_I NewMsgSendCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result, std::string clientMsgID) |
||||||
|
{ |
||||||
|
auto t = std::make_shared<MsgSendListenerCallBack>(result, clientMsgID); |
||||||
|
auto f = [t](const std::string &operationID, int state, const std::string &error, const std::string &msg, long progress) |
||||||
|
{ |
||||||
|
t->HandleCallback(operationID, state, error, msg, progress); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_callonce_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CustomBusinessListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::RECV_CUSTOM_BUSINESS_MESSAGE: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onRecvCustomBusinessMessage")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("customBusinessListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewCustomBusinessListenCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<CustomBusinessListenCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_callonce_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void GroupListenerCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
|
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::GROUP_APPLICATION_ACCEPTED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupApplicationAccepted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_APPLICATION_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupApplicationAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_APPLICATION_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupApplicationDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_APPLICATION_REJECTED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupApplicationRejected")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_DISMISSED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupDismissed")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_INFO_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupInfoChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_MEMBER_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupMemberAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_MEMBER_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupMemberDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::GROUP_MEMBER_INFO_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onGroupMemberInfoChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::JOINED_GROUP_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onJoinedGroupAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::JOINED_GROUP_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onJoinedGroupDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("groupListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewGroupListenerCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<GroupListenerCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ConversationListenerCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
json j; |
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::CONVERSATION_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onConversationChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CONVERSATION_USER_INPUT_STATUS_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onConversationUserInputStatusChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::NEW_CONVERSATION: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onNewConversation")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::SYNC_SERVER_FAILED: |
||||||
|
j = json::parse(msg); |
||||||
|
arguments.insert(std::make_pair("type", "onSyncServerFailed")); |
||||||
|
arguments.insert(std::make_pair("data", j.at("reinstalled").get<bool>())); |
||||||
|
break; |
||||||
|
case ConstDefine::SYNC_SERVER_FINISH: |
||||||
|
j = json::parse(msg); |
||||||
|
arguments.insert(std::make_pair("type", "onSyncServerFinish")); |
||||||
|
arguments.insert(std::make_pair("data", j.at("reinstalled").get<bool>())); |
||||||
|
break; |
||||||
|
case ConstDefine::SYNC_SERVER_START: |
||||||
|
j = json::parse(msg); |
||||||
|
arguments.insert(std::make_pair("type", "onSyncServerStart")); |
||||||
|
arguments.insert(std::make_pair("data", j.at("reinstalled").get<bool>())); |
||||||
|
break; |
||||||
|
case ConstDefine::SYNC_SERVER_PROGRESS: |
||||||
|
j = json::parse(msg); |
||||||
|
arguments.insert(std::make_pair("type", "onSyncServerProgress")); |
||||||
|
arguments.insert(std::make_pair("data", j.at("progress").get<int>())); |
||||||
|
break; |
||||||
|
case ConstDefine::TOTAL_UNREAD_MESSAGE_COUNT_CHANGED: |
||||||
|
j = json::parse(msg); |
||||||
|
arguments.insert(std::make_pair("type", "onTotalUnreadMessageCountChanged")); |
||||||
|
arguments.insert(std::make_pair("data", j.at("count").get<int>())); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("conversationListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewConversationListenerCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<ConversationListenerCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void FriendshipListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
|
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::BLACK_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onBlackAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::BLACK_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onBlackDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_APPLICATION_ACCEPTED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendApplicationAccepted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_APPLICATION_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendApplicationAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_APPLICATION_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendApplicationDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_APPLICATION_REJECTED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendApplicationRejected")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::FRIEND_INFO_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onFriendInfoChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("friendListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewFriendshipListenCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<FriendshipListenCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void ChannelListenCallBack::HandleCallback(int state, const std::string &msg) |
||||||
|
{ |
||||||
|
flutter::EncodableMap arguments; |
||||||
|
flutter::EncodableMap data; |
||||||
|
|
||||||
|
switch (ConstDefine(state)) |
||||||
|
{ |
||||||
|
case ConstDefine::CHANNEL_DISMISSED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onChannelDismissed")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CHANNEL_INFO_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onChannelInfoChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CHANNEL_MEMBER_ADDED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onChannelMemberAdded")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CHANNEL_MEMBER_DELETED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onChannelMemberDeleted")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
case ConstDefine::CHANNEL_MEMBER_INFO_CHANGED: |
||||||
|
|
||||||
|
arguments.insert(std::make_pair("type", "onChannelMemberInfoChanged")); |
||||||
|
arguments.insert(std::make_pair("data", msg)); |
||||||
|
break; |
||||||
|
} |
||||||
|
notifyEvent("channelListener", arguments); |
||||||
|
} |
||||||
|
|
||||||
|
CB_I_S NewChannelListenCallBack() |
||||||
|
{ |
||||||
|
auto t = std::make_shared<ChannelListenCallBack>(); |
||||||
|
auto f = [t](int state, const std::string &msg) |
||||||
|
{ |
||||||
|
t->HandleCallback(state, msg); |
||||||
|
}; |
||||||
|
|
||||||
|
return _wrapper_cpp_function(f); |
||||||
|
} |
||||||
|
@ -1,58 +1,203 @@ |
|||||||
#ifndef LISTEN_H |
#ifndef LISTEN_H |
||||||
#define LISTEN_H |
#define LISTEN_H |
||||||
|
|
||||||
#include <libopenimsdk.h> |
|
||||||
#include "flutter/encodable_value.h" |
#include "flutter/encodable_value.h" |
||||||
#include "flutter/method_result.h" |
#include "flutter/method_result.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
|
||||||
|
#include <functional> |
||||||
|
#include <string> |
||||||
|
#include <memory> |
||||||
|
#include <iostream> |
||||||
|
#include <bitset> |
||||||
|
#include <atomic> |
||||||
|
#include <thread> |
||||||
|
#include <chrono> |
||||||
|
#include <mutex> |
||||||
|
#include "../ThreadUtil.h" |
||||||
|
|
||||||
|
class BaseCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
BaseCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result_ptr) |
||||||
|
: result(result_ptr) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result = nullptr; |
||||||
|
|
||||||
|
void HandleCallback(const std::string &operationID, int errCode, const std::string &errMsg, |
||||||
|
const std::string &data) |
||||||
|
{ |
||||||
|
if (result == nullptr) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// Create shared pointers for the data to ensure copy constructibility
|
||||||
|
auto resultCopy = result; |
||||||
|
auto dataCopy = std::make_shared<std::string>(data); |
||||||
|
auto errCodeCopy = errCode; |
||||||
|
auto errMsgCopy = std::make_shared<std::string>(errMsg); |
||||||
|
|
||||||
|
// Ensure callback runs on the platform thread
|
||||||
|
ThreadUtil::RunOnPlatformThread([resultCopy, errCodeCopy, errMsgCopy, dataCopy]() |
||||||
|
{ |
||||||
|
if (errCodeCopy == 0) { |
||||||
|
resultCopy->Success(flutter::EncodableValue(*dataCopy)); |
||||||
|
} else { |
||||||
|
resultCopy->Error(std::to_string(errCodeCopy), *errMsgCopy, |
||||||
|
flutter::EncodableValue(*dataCopy)); |
||||||
|
} }); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
CB_S_I_S_S NewBaseCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
class BaseCallBack { |
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
class InitListenCallBack |
||||||
|
{ |
||||||
public: |
public: |
||||||
BaseCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
InitListenCallBack() |
||||||
this->result = result; |
{ |
||||||
} |
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string &msg); |
||||||
|
}; |
||||||
|
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result = nullptr; |
CB_I_S NewInitListenCallBack(); |
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void HandleCallback(char* opid, int errCode, char* errMsg, char* msg) { |
class UploadFileListenCallBack |
||||||
if (result == nullptr) { |
{ |
||||||
return; |
public: |
||||||
} |
UploadFileListenCallBack(std::string id) : id(id) |
||||||
|
{ |
||||||
|
} |
||||||
|
std::string id = ""; |
||||||
|
|
||||||
if (errCode == 0) { |
void HandleCallback(int state, const std::string &msg); |
||||||
result->Success(flutter::EncodableValue(std::string(msg))); |
|
||||||
} |
|
||||||
else { |
|
||||||
result->Error(std::to_string(errCode), std::string(errMsg), flutter::EncodableValue(std::string(msg))); |
|
||||||
} |
|
||||||
} |
|
||||||
}; |
}; |
||||||
|
|
||||||
// 全局映射表
|
CB_I_S NewUploadFileListenCallBack(std::string id); |
||||||
extern std::unordered_map<std::string, std::unique_ptr<BaseCallBack>> g_baseCallBackMap; |
|
||||||
extern std::mutex g_baseCallBackMapMutex; |
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class UploadLogsListenCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
UploadLogsListenCallBack() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
void NewBaseCallBack(std::string opid, std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
void HandleCallback(int state, const std::string &msg); |
||||||
void CallBaseCallBack(char* opid, int errCode, char* errMsg, char* msg); |
}; |
||||||
|
|
||||||
|
CB_I_S NewUploadLogsListenCallBack(); |
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//todo 没想好怎么实现
|
class UserListenCallBack |
||||||
class uploadFileCallBack { |
{ |
||||||
public: |
public: |
||||||
uploadFileCallBack(std::string id) { |
UserListenCallBack() |
||||||
this->id = id; |
{ |
||||||
} |
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string &msg); |
||||||
|
}; |
||||||
|
|
||||||
|
CB_I_S NewUserListenCallBack(); |
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class AdvancedMsgListenCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
AdvancedMsgListenCallBack(std::string id) : id(id) |
||||||
|
{ |
||||||
|
} |
||||||
std::string id = ""; |
std::string id = ""; |
||||||
|
|
||||||
void HandleCallback(char* opid, int errCode, char* errMsg, char* msg) { |
void HandleCallback(int state, const std::string &msg); |
||||||
|
}; |
||||||
|
|
||||||
|
CB_I_S NewAdvancedMsgListenCallBack(std::string id); |
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
class MsgSendListenerCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
MsgSendListenerCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result_ptr, std::string clientMsgID) : result(result_ptr), clientMsgID(clientMsgID) |
||||||
|
{ |
||||||
|
} |
||||||
|
std::string clientMsgID = ""; |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result = nullptr; |
||||||
|
void HandleCallback(const std::string &operationID, int state, const std::string &error, const std::string &msg, long progress); |
||||||
|
}; |
||||||
|
|
||||||
|
CB_S_I_S_S_I NewMsgSendCallBack(std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result, std::string clientMsgID); |
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class CustomBusinessListenCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
CustomBusinessListenCallBack() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string &msg); |
||||||
|
}; |
||||||
|
CB_I_S NewCustomBusinessListenCallBack(); |
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class GroupListenerCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
GroupListenerCallBack() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string &msg); |
||||||
|
}; |
||||||
|
|
||||||
|
CB_I_S NewGroupListenerCallBack(); |
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ConversationListenerCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
ConversationListenerCallBack() |
||||||
|
{ |
||||||
} |
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string &msg); |
||||||
}; |
}; |
||||||
|
|
||||||
|
CB_I_S NewConversationListenerCallBack(); |
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class FriendshipListenCallBack |
||||||
|
{ |
||||||
|
public: |
||||||
|
FriendshipListenCallBack() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string &msg); |
||||||
|
}; |
||||||
|
|
||||||
|
CB_I_S NewFriendshipListenCallBack(); |
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
class ChannelListenCallBack { |
||||||
|
public: |
||||||
|
ChannelListenCallBack() { |
||||||
|
} |
||||||
|
|
||||||
|
void HandleCallback(int state, const std::string& msg); |
||||||
|
}; |
||||||
|
|
||||||
|
CB_I_S NewChannelListenCallBack(); |
||||||
#endif |
#endif |
@ -0,0 +1,894 @@ |
|||||||
|
#include "MessageManager.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
#include "../NimResult.h" |
||||||
|
#include "../ZegoDataUtils.h" |
||||||
|
#include "ConstDefine.h" |
||||||
|
#include "Listen.h" |
||||||
|
|
||||||
|
MessageManagerService::MessageManagerService() { |
||||||
|
m_serviceName = "messageManager"; |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::onMethodCalled( |
||||||
|
const std::string& method, |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (method == "setAdvancedMsgListener") { |
||||||
|
setAdvancedMsgListener(arguments, result); |
||||||
|
} else if (method == "sendMessage") { |
||||||
|
sendMessage(arguments, result); |
||||||
|
} else if (method == "revokeMessage") { |
||||||
|
revokeMessage(arguments, result); |
||||||
|
} else if (method == "editMessage") { |
||||||
|
editMessage(arguments, result); |
||||||
|
} else if (method == "deleteMessageFromLocalStorage") { |
||||||
|
deleteMessageFromLocalStorage(arguments, result); |
||||||
|
} else if (method == "deleteMessageFromLocalAndSvr") { |
||||||
|
deleteMessageFromLocalAndSvr(arguments, result); |
||||||
|
} else if (method == "deleteAllMsgFromLocal") { |
||||||
|
deleteAllMsgFromLocal(arguments, result); |
||||||
|
} else if (method == "deleteAllMsgFromLocalAndSvr") { |
||||||
|
deleteAllMsgFromLocalAndSvr(arguments, result); |
||||||
|
} else if (method == "insertSingleMessageToLocalStorage") { |
||||||
|
insertSingleMessageToLocalStorage(arguments, result); |
||||||
|
} else if (method == "insertGroupMessageToLocalStorage") { |
||||||
|
insertGroupMessageToLocalStorage(arguments, result); |
||||||
|
} else if (method == "markMessagesAsReadByMsgID") { |
||||||
|
markMessagesAsReadByMsgID(arguments, result); |
||||||
|
} else if (method == "typingStatusUpdate") { |
||||||
|
typingStatusUpdate(arguments, result); |
||||||
|
} else if (method == "createTextMessage") { |
||||||
|
createTextMessage(arguments, result); |
||||||
|
} else if (method == "createTextAtMessage") { |
||||||
|
createTextAtMessage(arguments, result); |
||||||
|
} else if (method == "createImageMessage") { |
||||||
|
createImageMessage(arguments, result); |
||||||
|
} else if (method == "createImageMessageFromFullPath") { |
||||||
|
createImageMessageFromFullPath(arguments, result); |
||||||
|
} else if (method == "createSoundMessage") { |
||||||
|
createSoundMessage(arguments, result); |
||||||
|
} else if (method == "createSoundMessageFromFullPath") { |
||||||
|
createSoundMessageFromFullPath(arguments, result); |
||||||
|
} else if (method == "createVideoMessage") { |
||||||
|
createVideoMessage(arguments, result); |
||||||
|
} else if (method == "createVideoMessageFromFullPath") { |
||||||
|
createVideoMessageFromFullPath(arguments, result); |
||||||
|
} else if (method == "createFileMessage") { |
||||||
|
createFileMessage(arguments, result); |
||||||
|
} else if (method == "createFileMessageFromFullPath") { |
||||||
|
createFileMessageFromFullPath(arguments, result); |
||||||
|
} else if (method == "createMergerMessage") { |
||||||
|
createMergerMessage(arguments, result); |
||||||
|
} else if (method == "createForwardMessage") { |
||||||
|
createForwardMessage(arguments, result); |
||||||
|
} else if (method == "createLocationMessage") { |
||||||
|
createLocationMessage(arguments, result); |
||||||
|
} else if (method == "createCustomMessage") { |
||||||
|
createCustomMessage(arguments, result); |
||||||
|
} else if (method == "createQuoteMessage") { |
||||||
|
createQuoteMessage(arguments, result); |
||||||
|
} else if (method == "createCardMessage") { |
||||||
|
createCardMessage(arguments, result); |
||||||
|
} else if (method == "createFaceMessage") { |
||||||
|
createFaceMessage(arguments, result); |
||||||
|
} else if (method == "createAdvancedTextMessage") { |
||||||
|
createAdvancedTextMessage(arguments, result); |
||||||
|
} else if (method == "createAdvancedQuoteMessage") { |
||||||
|
createAdvancedQuoteMessage(arguments, result); |
||||||
|
} else if (method == "searchLocalMessages") { |
||||||
|
searchLocalMessages(arguments, result); |
||||||
|
} else if (method == "clearConversationAndDeleteAllMsg") { |
||||||
|
clearConversationAndDeleteAllMsg(arguments, result); |
||||||
|
} else if (method == "getAdvancedHistoryMessageList") { |
||||||
|
getAdvancedHistoryMessageList(arguments, result); |
||||||
|
} else if (method == "getAdvancedHistoryMessageListReverse") { |
||||||
|
getAdvancedHistoryMessageListReverse(arguments, result); |
||||||
|
} else if (method == "findMessageList") { |
||||||
|
findMessageList(arguments, result); |
||||||
|
} else if (method == "setMessageLocalEx") { |
||||||
|
setMessageLocalEx(arguments, result); |
||||||
|
} else if (method == "setAppBadge") { |
||||||
|
setAppBadge(arguments, result); |
||||||
|
} else if (method == "sendMessageNotOss") { |
||||||
|
sendMessageNotOss(arguments, result); |
||||||
|
} else if (method == "createImageMessageByURL") { |
||||||
|
createImageMessageByURL(arguments, result); |
||||||
|
} else if (method == "createSoundMessageByURL") { |
||||||
|
createSoundMessageByURL(arguments, result); |
||||||
|
} else if (method == "createVideoMessageByURL") { |
||||||
|
createVideoMessageByURL(arguments, result); |
||||||
|
} else if (method == "createFileMessageByURL") { |
||||||
|
createFileMessageByURL(arguments, result); |
||||||
|
} else if (method == "fetchSurroundingMessages") { |
||||||
|
fetchSurroundingMessages(arguments, result); |
||||||
|
} else if (method == "setCustomBusinessListener") { |
||||||
|
setCustomBusinessListener(arguments, result); |
||||||
|
} else { |
||||||
|
result->NotImplemented(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::setAdvancedMsgListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto id = zego_value_get_string(arguments->at(flutter::EncodableValue("id"))); |
||||||
|
set_advanced_msg_listener(NewAdvancedMsgListenCallBack(id)); |
||||||
|
result->Success(flutter::EncodableValue()); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::sendMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID"))); |
||||||
|
auto groupID = zego_value_get_string(arguments->at(flutter::EncodableValue("groupID"))); |
||||||
|
auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); |
||||||
|
auto offlinePushInfo = zego_value_get_string(arguments->at(flutter::EncodableValue("offlinePushInfo"))); |
||||||
|
auto isOnlineOnly = zego_value_get_bool(arguments->at(flutter::EncodableValue("isOnlineOnly"))); |
||||||
|
auto clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
|
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(channelID.c_str()); |
||||||
|
char* offlinePushInfo_cs = const_cast<char*>(offlinePushInfo.c_str()); |
||||||
|
|
||||||
|
send_message(NewMsgSendCallBack(result,clientMsgID), operationID_cs, message_cs, userID_cs, groupID_cs, channelID_cs, offlinePushInfo_cs, isOnlineOnly); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::revokeMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* clientMsgID_cs = const_cast<char*>(clientMsgID.c_str()); |
||||||
|
|
||||||
|
revoke_message(NewBaseCallBack(result), operationID_cs, conversationID_cs, clientMsgID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::editMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* clientMsgID_cs = const_cast<char*>(clientMsgID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
|
||||||
|
edit_message(NewBaseCallBack(result), operationID_cs, conversationID_cs, clientMsgID_cs, message_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::deleteMessageFromLocalStorage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* clientMsgID_cs = const_cast<char*>(clientMsgID.c_str()); |
||||||
|
|
||||||
|
delete_message_from_local_storage(NewBaseCallBack(result), operationID_cs, conversationID_cs, clientMsgID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::deleteMessageFromLocalAndSvr( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* clientMsgID_cs = const_cast<char*>(clientMsgID.c_str()); |
||||||
|
|
||||||
|
delete_message(NewBaseCallBack(result), operationID_cs, conversationID_cs, clientMsgID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::deleteAllMsgFromLocal( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
delete_all_msg_from_local(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::deleteAllMsgFromLocalAndSvr( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
delete_all_msg_from_local_and_svr(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::insertSingleMessageToLocalStorage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
auto receiverID = zego_value_get_string(arguments->at(flutter::EncodableValue("receiverID"))); |
||||||
|
auto senderID = zego_value_get_string(arguments->at(flutter::EncodableValue("senderID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
char* receiverID_cs = const_cast<char*>(receiverID.c_str()); |
||||||
|
char* senderID_cs = const_cast<char*>(senderID.c_str()); |
||||||
|
|
||||||
|
insert_single_message_to_local_storage(NewBaseCallBack(result), operationID_cs, message_cs, receiverID_cs, senderID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::insertGroupMessageToLocalStorage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
auto groupID = zego_value_get_string(arguments->at(flutter::EncodableValue("groupID"))); |
||||||
|
auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); |
||||||
|
auto senderID = zego_value_get_string(arguments->at(flutter::EncodableValue("senderID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* channelID_cs = const_cast<char*>(channelID.c_str()); |
||||||
|
char* senderID_cs = const_cast<char*>(senderID.c_str()); |
||||||
|
|
||||||
|
insert_group_message_to_local_storage(NewBaseCallBack(result), operationID_cs, message_cs, groupID_cs, channelID_cs, senderID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::markMessagesAsReadByMsgID( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 messageIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("messageIDList"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* messageIDList_cs = const_cast<char*>(messageIDList.c_str()); |
||||||
|
|
||||||
|
mark_messages_as_read_by_msg_id(NewBaseCallBack(result), operationID_cs, conversationID_cs, messageIDList_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::typingStatusUpdate( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 msgTip = zego_value_get_string(arguments->at(flutter::EncodableValue("msgTip"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
char* msgTip_cs = const_cast<char*>(msgTip.c_str()); |
||||||
|
|
||||||
|
typing_status_update(NewBaseCallBack(result), operationID_cs, userID_cs, msgTip_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createTextMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto text = zego_value_get_string(arguments->at(flutter::EncodableValue("text"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* text_cs = const_cast<char*>(text.c_str()); |
||||||
|
|
||||||
|
std::string message = create_text_message(operationID_cs, text_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createTextAtMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto text = zego_value_get_string(arguments->at(flutter::EncodableValue("text"))); |
||||||
|
auto atUserIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("atUserIDList"))); |
||||||
|
auto atUserInfoList = zego_value_get_string(arguments->at(flutter::EncodableValue("atUserInfoList"))); |
||||||
|
auto quoteMessage = zego_value_get_string(arguments->at(flutter::EncodableValue("quoteMessage"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* text_cs = const_cast<char*>(text.c_str()); |
||||||
|
char* atUserIDList_cs = const_cast<char*>(atUserIDList.c_str()); |
||||||
|
char* atUserInfoList_cs = const_cast<char*>(atUserInfoList.c_str()); |
||||||
|
char* quoteMessage_cs = const_cast<char*>(quoteMessage.c_str()); |
||||||
|
|
||||||
|
std::string message = create_text_at_message(operationID_cs, text_cs, atUserIDList_cs, atUserInfoList_cs, quoteMessage_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createImageMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto imagePath = zego_value_get_string(arguments->at(flutter::EncodableValue("imagePath"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* imagePath_cs = const_cast<char*>(imagePath.c_str()); |
||||||
|
|
||||||
|
std::string message = create_image_message(operationID_cs, imagePath_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createImageMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto imagePath = zego_value_get_string(arguments->at(flutter::EncodableValue("imagePath"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* imagePath_cs = const_cast<char*>(imagePath.c_str()); |
||||||
|
|
||||||
|
std::string message = create_image_message_from_full_path(operationID_cs, imagePath_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createSoundMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto soundPath = zego_value_get_string(arguments->at(flutter::EncodableValue("soundPath"))); |
||||||
|
auto duration = zego_value_get_int(arguments->at(flutter::EncodableValue("duration"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* soundPath_cs = const_cast<char*>(soundPath.c_str()); |
||||||
|
|
||||||
|
std::string message = create_sound_message(operationID_cs, soundPath_cs, duration); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createSoundMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto soundPath = zego_value_get_string(arguments->at(flutter::EncodableValue("soundPath"))); |
||||||
|
auto duration = zego_value_get_int(arguments->at(flutter::EncodableValue("duration"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* soundPath_cs = const_cast<char*>(soundPath.c_str()); |
||||||
|
|
||||||
|
std::string message = create_sound_message_from_full_path(operationID_cs, soundPath_cs, duration); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createVideoMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto videoPath = zego_value_get_string(arguments->at(flutter::EncodableValue("videoPath"))); |
||||||
|
auto videoType = zego_value_get_string(arguments->at(flutter::EncodableValue("videoType"))); |
||||||
|
auto duration = zego_value_get_int(arguments->at(flutter::EncodableValue("duration"))); |
||||||
|
auto snapshotPath = zego_value_get_string(arguments->at(flutter::EncodableValue("snapshotPath"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* videoPath_cs = const_cast<char*>(videoPath.c_str()); |
||||||
|
char* videoType_cs = const_cast<char*>(videoType.c_str()); |
||||||
|
char* snapshotPath_cs = const_cast<char*>(snapshotPath.c_str()); |
||||||
|
|
||||||
|
std::string message = create_video_message(operationID_cs, videoPath_cs, videoType_cs, duration, snapshotPath_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createVideoMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto videoPath = zego_value_get_string(arguments->at(flutter::EncodableValue("videoPath"))); |
||||||
|
auto videoType = zego_value_get_string(arguments->at(flutter::EncodableValue("videoType"))); |
||||||
|
auto duration = zego_value_get_int(arguments->at(flutter::EncodableValue("duration"))); |
||||||
|
auto snapshotPath = zego_value_get_string(arguments->at(flutter::EncodableValue("snapshotPath"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* videoPath_cs = const_cast<char*>(videoPath.c_str()); |
||||||
|
char* videoType_cs = const_cast<char*>(videoType.c_str()); |
||||||
|
char* snapshotPath_cs = const_cast<char*>(snapshotPath.c_str()); |
||||||
|
|
||||||
|
std::string message = create_video_message_from_full_path(operationID_cs, videoPath_cs, videoType_cs, duration, snapshotPath_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createFileMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto filePath = zego_value_get_string(arguments->at(flutter::EncodableValue("filePath"))); |
||||||
|
auto fileName = zego_value_get_string(arguments->at(flutter::EncodableValue("fileName"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* filePath_cs = const_cast<char*>(filePath.c_str()); |
||||||
|
char* fileName_cs = const_cast<char*>(fileName.c_str()); |
||||||
|
|
||||||
|
std::string message = create_file_message(operationID_cs, filePath_cs, fileName_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createFileMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto filePath = zego_value_get_string(arguments->at(flutter::EncodableValue("filePath"))); |
||||||
|
auto fileName = zego_value_get_string(arguments->at(flutter::EncodableValue("fileName"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* filePath_cs = const_cast<char*>(filePath.c_str()); |
||||||
|
char* fileName_cs = const_cast<char*>(fileName.c_str()); |
||||||
|
|
||||||
|
std::string message = create_file_message_from_full_path(operationID_cs, filePath_cs, fileName_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createMergerMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto messageList = zego_value_get_string(arguments->at(flutter::EncodableValue("messageList"))); |
||||||
|
auto title = zego_value_get_string(arguments->at(flutter::EncodableValue("title"))); |
||||||
|
auto summaryList = zego_value_get_string(arguments->at(flutter::EncodableValue("summaryList"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* messageList_cs = const_cast<char*>(messageList.c_str()); |
||||||
|
char* title_cs = const_cast<char*>(title.c_str()); |
||||||
|
char* summaryList_cs = const_cast<char*>(summaryList.c_str()); |
||||||
|
|
||||||
|
std::string message = create_merger_message(operationID_cs, messageList_cs, title_cs, summaryList_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createForwardMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
|
||||||
|
std::string resultMessage = create_forward_message(operationID_cs, message_cs); |
||||||
|
result->Success(flutter::EncodableValue(resultMessage)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createLocationMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto description = zego_value_get_string(arguments->at(flutter::EncodableValue("description"))); |
||||||
|
auto longitude = zego_value_get_double(arguments->at(flutter::EncodableValue("longitude"))); |
||||||
|
auto latitude = zego_value_get_double(arguments->at(flutter::EncodableValue("latitude"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* description_cs = const_cast<char*>(description.c_str()); |
||||||
|
|
||||||
|
|
||||||
|
std::string message = create_location_message(operationID_cs, description_cs, longitude, latitude); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createCustomMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto data = zego_value_get_string(arguments->at(flutter::EncodableValue("data"))); |
||||||
|
auto extension = zego_value_get_string(arguments->at(flutter::EncodableValue("extension"))); |
||||||
|
auto description = zego_value_get_string(arguments->at(flutter::EncodableValue("description"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* data_cs = const_cast<char*>(data.c_str()); |
||||||
|
char* extension_cs = const_cast<char*>(extension.c_str()); |
||||||
|
char* description_cs = const_cast<char*>(description.c_str()); |
||||||
|
|
||||||
|
std::string message = create_custom_message(operationID_cs, data_cs, extension_cs, description_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createQuoteMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto quoteText = zego_value_get_string(arguments->at(flutter::EncodableValue("quoteText"))); |
||||||
|
auto quoteMessage = zego_value_get_string(arguments->at(flutter::EncodableValue("quoteMessage"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* quoteText_cs = const_cast<char*>(quoteText.c_str()); |
||||||
|
char* quoteMessage_cs = const_cast<char*>(quoteMessage.c_str()); |
||||||
|
|
||||||
|
std::string message = create_quote_message(operationID_cs, quoteText_cs, quoteMessage_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createCardMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto cardMessage = zego_value_get_string(arguments->at(flutter::EncodableValue("cardMessage"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* cardMessage_cs = const_cast<char*>(cardMessage.c_str()); |
||||||
|
|
||||||
|
std::string message = create_card_message(operationID_cs, cardMessage_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createFaceMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto index = zego_value_get_int(arguments->at(flutter::EncodableValue("index"))); |
||||||
|
auto data = zego_value_get_string(arguments->at(flutter::EncodableValue("data"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* data_cs = const_cast<char*>(data.c_str()); |
||||||
|
|
||||||
|
std::string message = create_face_message(operationID_cs, index, data_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createAdvancedTextMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto text = zego_value_get_string(arguments->at(flutter::EncodableValue("text"))); |
||||||
|
auto richMessageInfoList = zego_value_get_string(arguments->at(flutter::EncodableValue("richMessageInfoList"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* text_cs = const_cast<char*>(text.c_str()); |
||||||
|
char* richMessageInfoList_cs = const_cast<char*>(richMessageInfoList.c_str()); |
||||||
|
|
||||||
|
std::string message = create_advanced_text_message(operationID_cs, text_cs, richMessageInfoList_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createAdvancedQuoteMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto quoteText = zego_value_get_string(arguments->at(flutter::EncodableValue("quoteText"))); |
||||||
|
auto quoteMessage = zego_value_get_string(arguments->at(flutter::EncodableValue("quoteMessage"))); |
||||||
|
auto richMessageInfoList = zego_value_get_string(arguments->at(flutter::EncodableValue("richMessageInfoList"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* quoteText_cs = const_cast<char*>(quoteText.c_str()); |
||||||
|
char* quoteMessage_cs = const_cast<char*>(quoteMessage.c_str()); |
||||||
|
char* richMessageInfoList_cs = const_cast<char*>(richMessageInfoList.c_str()); |
||||||
|
|
||||||
|
std::string message = create_advanced_quote_message(operationID_cs, quoteText_cs, quoteMessage_cs, richMessageInfoList_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::searchLocalMessages( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto filter = zego_value_get_string(arguments->at(flutter::EncodableValue("filter"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* filter_cs = const_cast<char*>(filter.c_str()); |
||||||
|
|
||||||
|
search_local_messages(NewBaseCallBack(result), operationID_cs, filter_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::clearConversationAndDeleteAllMsg( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(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 MessageManagerService::getAdvancedHistoryMessageList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto params = map_2_json(*arguments); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* params_cs = const_cast<char*>(params.c_str()); |
||||||
|
|
||||||
|
get_advanced_history_message_list(NewBaseCallBack(result), operationID_cs, params_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::getAdvancedHistoryMessageListReverse( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto params = map_2_json(*arguments); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* params_cs = const_cast<char*>(params.c_str()); |
||||||
|
|
||||||
|
get_advanced_history_message_list_reverse(NewBaseCallBack(result), operationID_cs, params_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::findMessageList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto searchParams = zego_value_get_string(arguments->at(flutter::EncodableValue("searchParams"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* searchParams_cs = const_cast<char*>(searchParams.c_str()); |
||||||
|
|
||||||
|
find_message_list(NewBaseCallBack(result), operationID_cs, searchParams_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::setMessageLocalEx( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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 clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
auto localEx = zego_value_get_string(arguments->at(flutter::EncodableValue("localEx"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* conversationID_cs = const_cast<char*>(conversationID.c_str()); |
||||||
|
char* clientMsgID_cs = const_cast<char*>(clientMsgID.c_str()); |
||||||
|
char* localEx_cs = const_cast<char*>(localEx.c_str()); |
||||||
|
|
||||||
|
set_message_local_ex(NewBaseCallBack(result), operationID_cs, conversationID_cs, clientMsgID_cs, localEx_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::setAppBadge( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
set_app_Badge(NewBaseCallBack(result), operationID_cs, count); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::sendMessageNotOss( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID"))); |
||||||
|
auto groupID = zego_value_get_string(arguments->at(flutter::EncodableValue("groupID"))); |
||||||
|
auto channelId = zego_value_get_string(arguments->at(flutter::EncodableValue("channelId"))); |
||||||
|
auto offlinePushInfo = zego_value_get_string(arguments->at(flutter::EncodableValue("offlinePushInfo"))); |
||||||
|
auto clientMsgID = zego_value_get_string(arguments->at(flutter::EncodableValue("clientMsgID"))); |
||||||
|
auto isOnlineOnly = zego_value_get_bool(arguments->at(flutter::EncodableValue("isOnlineOnly"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
char* userID_cs = const_cast<char*>(userID.c_str()); |
||||||
|
char* groupID_cs = const_cast<char*>(groupID.c_str()); |
||||||
|
char* channelId_cs = const_cast<char*>(channelId.c_str()); |
||||||
|
char* offlinePushInfo_cs = const_cast<char*>(offlinePushInfo.c_str()); |
||||||
|
|
||||||
|
send_message_not_oss(NewMsgSendCallBack(result,clientMsgID), operationID_cs, message_cs, userID_cs, groupID_cs, channelId_cs, offlinePushInfo_cs, isOnlineOnly); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createImageMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto sourcePath = zego_value_get_string(arguments->at(flutter::EncodableValue("sourcePath"))); |
||||||
|
auto sourcePicture = zego_value_get_string(arguments->at(flutter::EncodableValue("sourcePicture"))); |
||||||
|
auto bigPicture = zego_value_get_string(arguments->at(flutter::EncodableValue("bigPicture"))); |
||||||
|
auto snapshotPicture = zego_value_get_string(arguments->at(flutter::EncodableValue("snapshotPicture"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* sourcePath_cs = const_cast<char*>(sourcePath.c_str()); |
||||||
|
char* sourcePicture_cs = const_cast<char*>(sourcePicture.c_str()); |
||||||
|
char* bigPicture_cs = const_cast<char*>(bigPicture.c_str()); |
||||||
|
char* snapshotPicture_cs = const_cast<char*>(snapshotPicture.c_str()); |
||||||
|
|
||||||
|
std::string message = create_image_message_by_url(operationID_cs, sourcePath_cs, sourcePicture_cs, bigPicture_cs, snapshotPicture_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createSoundMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto soundElem = zego_value_get_string(arguments->at(flutter::EncodableValue("soundElem"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* soundElem_cs = const_cast<char*>(soundElem.c_str()); |
||||||
|
|
||||||
|
std::string message = create_sound_message_by_url(operationID_cs, soundElem_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createVideoMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto videoElem = zego_value_get_string(arguments->at(flutter::EncodableValue("videoElem"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* videoElem_cs = const_cast<char*>(videoElem.c_str()); |
||||||
|
|
||||||
|
std::string message = create_video_message_by_url(operationID_cs, videoElem_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::createFileMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto fileElem = zego_value_get_string(arguments->at(flutter::EncodableValue("fileElem"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* fileElem_cs = const_cast<char*>(fileElem.c_str()); |
||||||
|
|
||||||
|
std::string message = create_file_message_by_url(operationID_cs, fileElem_cs); |
||||||
|
result->Success(flutter::EncodableValue(message)); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::fetchSurroundingMessages( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto message = zego_value_get_string(arguments->at(flutter::EncodableValue("message"))); |
||||||
|
auto before = zego_value_get_int(arguments->at(flutter::EncodableValue("before"))); |
||||||
|
auto after = zego_value_get_int(arguments->at(flutter::EncodableValue("after"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* message_cs = const_cast<char*>(message.c_str()); |
||||||
|
|
||||||
|
fetch_surrounding_messages(NewBaseCallBack(result), operationID_cs, message_cs, before, after); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void MessageManagerService::setCustomBusinessListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
set_custom_business_listener(NewCustomBusinessListenCallBack()); |
||||||
|
result->Success(flutter::EncodableValue()); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,159 @@ |
|||||||
|
#ifndef MESSAGE_MANAGER_SERVICE_H |
||||||
|
#define MESSAGE_MANAGER_SERVICE_H |
||||||
|
#include "../FLTService.h" |
||||||
|
#include "Listen.h" |
||||||
|
#include <flutter/standard_method_codec.h> |
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
class MessageManagerService : public FLTService { |
||||||
|
public: |
||||||
|
MessageManagerService(); |
||||||
|
|
||||||
|
void onMethodCalled( |
||||||
|
const std::string& method, |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
// Method handlers
|
||||||
|
void setAdvancedMsgListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void sendMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void revokeMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void editMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void deleteMessageFromLocalStorage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void deleteMessageFromLocalAndSvr( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void deleteAllMsgFromLocal( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void deleteAllMsgFromLocalAndSvr( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void insertSingleMessageToLocalStorage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void insertGroupMessageToLocalStorage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void markMessagesAsReadByMsgID( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void typingStatusUpdate( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createTextMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createTextAtMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createImageMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createImageMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createSoundMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createSoundMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createVideoMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createVideoMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createFileMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createFileMessageFromFullPath( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createMergerMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createForwardMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createLocationMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createCustomMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createQuoteMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createCardMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createFaceMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createAdvancedTextMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createAdvancedQuoteMessage( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void searchLocalMessages( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void clearConversationAndDeleteAllMsg( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getAdvancedHistoryMessageList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getAdvancedHistoryMessageListReverse( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void findMessageList( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setMessageLocalEx( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setAppBadge( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void sendMessageNotOss( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createImageMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createSoundMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createVideoMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void createFileMessageByURL( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void fetchSurroundingMessages( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setCustomBusinessListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
private: |
||||||
|
std::string m_serviceName; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // MESSAGE_MANAGER_SERVICE_H
|
@ -0,0 +1,150 @@ |
|||||||
|
#include "UserManager.h" |
||||||
|
#include <libopenimsdk.h> |
||||||
|
#include "../NimResult.h" |
||||||
|
#include "../ZegoDataUtils.h" |
||||||
|
#include "ConstDefine.h" |
||||||
|
#include "Listen.h" |
||||||
|
|
||||||
|
UserManagerService::UserManagerService() { |
||||||
|
m_serviceName = "userManager"; |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::onMethodCalled( |
||||||
|
const std::string& method, |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (method == "setUserListener") { |
||||||
|
setUserListener(arguments, result); |
||||||
|
} else if (method == "getUsersInfo") { |
||||||
|
getUsersInfo(arguments, result); |
||||||
|
} else if (method == "setSelfInfo") { |
||||||
|
setSelfInfo(arguments, result); |
||||||
|
} else if (method == "getSelfUserInfo") { |
||||||
|
getSelfUserInfo(arguments, result); |
||||||
|
} else if (method == "subscribeUsersStatus") { |
||||||
|
subscribeUsersStatus(arguments, result); |
||||||
|
} else if (method == "unsubscribeUsersStatus") { |
||||||
|
unsubscribeUsersStatus(arguments, result); |
||||||
|
} else if (method == "getSubscribeUsersStatus") { |
||||||
|
getSubscribeUsersStatus(arguments, result); |
||||||
|
} else if (method == "getUserStatus") { |
||||||
|
getUserStatus(arguments, result); |
||||||
|
} else { |
||||||
|
result->NotImplemented(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::setUserListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
set_user_listener(NewUserListenCallBack()); |
||||||
|
result->Success(flutter::EncodableValue()); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::getUsersInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> 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<char*>(operationID.c_str()); |
||||||
|
char* userIDList_cs = const_cast<char*>(userIDList.c_str()); |
||||||
|
|
||||||
|
get_users_info(NewBaseCallBack(result), operationID_cs, userIDList_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::setSelfInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto userInfo = map_2_json(*arguments); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* userInfo_cs = const_cast<char*>(userInfo.c_str()); |
||||||
|
|
||||||
|
set_self_info(NewBaseCallBack(result), operationID_cs, userInfo_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::getSelfUserInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
get_self_user_info(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::subscribeUsersStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto userIDs = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDs"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str()); |
||||||
|
|
||||||
|
subscribe_users_status(NewBaseCallBack(result), operationID_cs, userIDs_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::unsubscribeUsersStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto userIDs = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDs"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str()); |
||||||
|
|
||||||
|
unsubscribe_users_status(NewBaseCallBack(result), operationID_cs, userIDs_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::getSubscribeUsersStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
|
||||||
|
get_subscribe_users_status(NewBaseCallBack(result), operationID_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void UserManagerService::getUserStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { |
||||||
|
if (arguments) { |
||||||
|
auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); |
||||||
|
auto userIDs = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDs"))); |
||||||
|
char* operationID_cs = const_cast<char*>(operationID.c_str()); |
||||||
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str()); |
||||||
|
|
||||||
|
get_user_status(NewBaseCallBack(result), operationID_cs, userIDs_cs); |
||||||
|
} else { |
||||||
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,49 @@ |
|||||||
|
#ifndef USER_MANAGER_SERVICE_H |
||||||
|
#define USER_MANAGER_SERVICE_H |
||||||
|
|
||||||
|
#include "../FLTService.h" |
||||||
|
#include "Listen.h" |
||||||
|
#include <flutter/standard_method_codec.h> |
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
class UserManagerService : public FLTService { |
||||||
|
public: |
||||||
|
UserManagerService(); |
||||||
|
|
||||||
|
void onMethodCalled( |
||||||
|
const std::string& method, |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
// Method handlers
|
||||||
|
void setUserListener( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getUsersInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void setSelfInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getSelfUserInfo( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void subscribeUsersStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void unsubscribeUsersStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getSubscribeUsersStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
void getUserStatus( |
||||||
|
const flutter::EncodableMap* arguments, |
||||||
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result); |
||||||
|
|
||||||
|
private: |
||||||
|
std::string m_serviceName; |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // USER_MANAGER_SERVICE_H
|
Loading…
Reference in new issue