#include "ChannelManager.h" #include #include "../NimResult.h" #include "../ZegoDataUtils.h" #include "ConstDefine.h" #include "Listen.h" ChannelManagerService::ChannelManagerService() { m_serviceName = "channelManager"; } void ChannelManagerService::onMethodCalled( const std::string& method, const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (method == "setChannelListener") { setChannelListener(arguments, result); } else if (method == "getChannelMembersInfo") { getChannelMembersInfo(arguments, result); } else if (method == "getChannelMemberList") { getChannelMemberList(arguments, result); } else if (method == "getChannelsInfo") { getChannelsInfo(arguments, result); } else if (method == "joinChannel") { joinChannel(arguments, result); } else if (method == "quitChannel") { quitChannel(arguments, result); } else if (method == "changeChannelMute") { changeChannelMute(arguments, result); } else if (method == "changeChannelMemberMute") { changeChannelMemberMute(arguments, result); } else if (method == "isJoinChannel") { isJoinChannel(arguments, result); } else if (method == "getUsersInChannel") { getUsersInChannel(arguments, result); } else { result->NotImplemented(); } } void ChannelManagerService::setChannelListener( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { set_channel_listener(NewChannelListenCallBack()); result->Success(flutter::EncodableValue()); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::getChannelMembersInfo( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); auto userIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDList"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelID_cs = const_cast(channelID.c_str()); char* userIDList_cs = const_cast(userIDList.c_str()); get_specified_channel_members_info(NewBaseCallBack(result), operationID_cs, channelID_cs, userIDList_cs); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::getChannelMemberList( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); auto filter = zego_value_get_int(arguments->at(flutter::EncodableValue("filter"))); auto offset = zego_value_get_int(arguments->at(flutter::EncodableValue("offset"))); auto count = zego_value_get_int(arguments->at(flutter::EncodableValue("count"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelID_cs = const_cast(channelID.c_str()); get_channel_member_list(NewBaseCallBack(result), operationID_cs, channelID_cs, filter, offset, count); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::getChannelsInfo( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelIDList = zego_value_get_string(arguments->at(flutter::EncodableValue("channelIDList"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelIDList_cs = const_cast(channelIDList.c_str()); get_specified_channels_info(NewBaseCallBack(result), operationID_cs, channelIDList_cs); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::joinChannel( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); auto reason = zego_value_get_string(arguments->at(flutter::EncodableValue("reason"))); auto joinSource = zego_value_get_int(arguments->at(flutter::EncodableValue("joinSource"))); auto ex = zego_value_get_string(arguments->at(flutter::EncodableValue("ex"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelID_cs = const_cast(channelID.c_str()); char* reason_cs = const_cast(reason.c_str()); char* ex_cs = const_cast(ex.c_str()); join_channel(NewBaseCallBack(result), operationID_cs, channelID_cs, reason_cs, joinSource, ex_cs); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::quitChannel( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelID_cs = const_cast(channelID.c_str()); quit_channel(NewBaseCallBack(result), operationID_cs, channelID_cs); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::changeChannelMute( const flutter::EncodableMap* arguments, std::shared_ptr> result) { // if (arguments) { // auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); // auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); // auto mute = zego_value_get_bool(arguments->at(flutter::EncodableValue("mute"))); // char* operationID_cs = const_cast(operationID.c_str()); // char* channelID_cs = const_cast(channelID.c_str()); // change_channel_mute(NewBaseCallBack(result), operationID_cs, channelID_cs, mute); // } else { // result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); // } } void ChannelManagerService::changeChannelMemberMute( const flutter::EncodableMap* arguments, std::shared_ptr> result) { // if (arguments) { // auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); // auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); // auto userID = zego_value_get_string(arguments->at(flutter::EncodableValue("userID"))); // auto seconds = zego_value_get_int(arguments->at(flutter::EncodableValue("seconds"))); // char* operationID_cs = const_cast(operationID.c_str()); // char* channelID_cs = const_cast(channelID.c_str()); // char* userID_cs = const_cast(userID.c_str()); // change_channel_member_mute(NewBaseCallBack(result), operationID_cs, channelID_cs, userID_cs, seconds); // } else { // result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); // } } void ChannelManagerService::isJoinChannel( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelID_cs = const_cast(channelID.c_str()); is_join_channel(NewBaseCallBack(result), operationID_cs, channelID_cs); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } } void ChannelManagerService::getUsersInChannel( const flutter::EncodableMap* arguments, std::shared_ptr> result) { if (arguments) { auto operationID = zego_value_get_string(arguments->at(flutter::EncodableValue("operationID"))); auto channelID = zego_value_get_string(arguments->at(flutter::EncodableValue("channelID"))); auto userIDs = zego_value_get_string(arguments->at(flutter::EncodableValue("userIDs"))); char* operationID_cs = const_cast(operationID.c_str()); char* channelID_cs = const_cast(channelID.c_str()); char* userIDs_cs = const_cast(userIDs.c_str()); get_users_in_channel(NewBaseCallBack(result), operationID_cs, channelID_cs, userIDs_cs); } else { result->Error("INVALID_ARGUMENT", "Arguments cannot be null"); } }