#import "ExtSdkDispatch.h"
#import "ExtSdkDelegateObjc.h"
#import "ExtSdkMethodTypeObjc.h"
#import "ExtSdkTypeUtilObjc.h"

#import "ExtSdkChatManagerWrapper.h"
#import "ExtSdkChatroomManagerWrapper.h"
#import "ExtSdkClientWrapper.h"
#import "ExtSdkContactManagerWrapper.h"
#import "ExtSdkConversationWrapper.h"
#import "ExtSdkGroupManagerWrapper.h"
#import "ExtSdkPresenceManagerWrapper.h"
#import "ExtSdkPushManagerWrapper.h"
#import "ExtSdkUserInfoManagerWrapper.h"

static NSString *const TAG = @"ExtSdkDispatch";
@interface ExtSdkDispatch () {
    id<ExtSdkDelegateObjc> _listener;
}

@end

@implementation ExtSdkDispatch

+ (nonnull instancetype)getInstance {
    static ExtSdkDispatch *instance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
      instance = [[ExtSdkDispatch alloc] init];
    });
    return instance;
}

- (void)addListener:(nonnull id<ExtSdkDelegateObjc>)listener {
    NSLog(@"%@: addListener:", TAG);
    _listener = listener;
}

- (void)callSdkApi:(nonnull NSString *)methodType withParams:(nullable id<NSObject>)params withCallback:(nonnull id<ExtSdkCallbackObjc>)callback {
    NSLog(@"%@: callSdkApi: %@, %@", TAG, methodType, params != nil ? params : @"");
    NSDictionary *ps = (NSDictionary *)params;

    if ([ExtSdkTypeUtilObjc currentArchitectureType] == ExtSdkArchitectureTypeValueFlutter) {

    } else if ([ExtSdkTypeUtilObjc currentArchitectureType] == ExtSdkArchitectureTypeValueUnity) {

    } else if ([ExtSdkTypeUtilObjc currentArchitectureType] == ExtSdkArchitectureTypeValueRN) {
        NSArray *a = [ps allValues];
        ps = a.firstObject;
    } else {
        @throw @"This type is not supported.";
    }

    switch ([ExtSdkMethodTypeObjc getEnumValue:methodType]) {

    /// #pragma mark - EMClientWrapper value
    case ExtSdkMethodKeyInitValue:
        [[ExtSdkClientWrapper getInstance] initSDKWithDict:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyCreateAccountValue:
        [[ExtSdkClientWrapper getInstance] createAccount:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoginValue:
        [[ExtSdkClientWrapper getInstance] login:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLogoutValue:
        [[ExtSdkClientWrapper getInstance] logout:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChangeAppKeyValue:
        [[ExtSdkClientWrapper getInstance] changeAppKey:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyIsLoggedInBeforeValue:
        [[ExtSdkClientWrapper getInstance] isLoggedInBefore:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUploadLogValue:
        [[ExtSdkClientWrapper getInstance] uploadLog:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyCompressLogsValue:
        [[ExtSdkClientWrapper getInstance] compressLogs:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyKickDeviceValue:
        [[ExtSdkClientWrapper getInstance] kickDevice:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyKickAllDevicesValue:
        [[ExtSdkClientWrapper getInstance] kickAllDevices:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyCurrentUserValue:
        [[ExtSdkClientWrapper getInstance] getCurrentUser:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetLoggedInDevicesFromServerValue:
        [[ExtSdkClientWrapper getInstance] getLoggedInDevicesFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetTokenValue:
        [[ExtSdkClientWrapper getInstance] getToken:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoginWithAgoraTokenValue:
        [[ExtSdkClientWrapper getInstance] loginWithAgoraToken:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyIsConnectedValue:
        [[ExtSdkClientWrapper getInstance] isConnected:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetCurrentUserValue:
        [[ExtSdkClientWrapper getInstance] getCurrentUser:ps withMethodType:methodType result:callback];
        break;

    /// #pragma mark - EMClientDelegate value
    case ExtSdkMethodKeyOnConnectedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnDisconnectedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMultiDeviceEventValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeySendDataToFlutterValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnTokenWillExpireValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnTokenDidExpireValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserDidLoginFromOtherDeviceValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserDidRemoveFromServerValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserDidForbidByServerValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserDidChangePasswordValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserDidLoginTooManyDeviceValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserKickedByOtherDeviceValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnUserAuthenticationFailedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

    /// #pragma mark - EMContactManagerWrapper value
    case ExtSdkMethodKeyAddContactValue:
        [[ExtSdkContactManagerWrapper getInstance] addContact:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDeleteContactValue:
        [[ExtSdkContactManagerWrapper getInstance] deleteContact:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetAllContactsFromServerValue:
        [[ExtSdkContactManagerWrapper getInstance] getAllContactsFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetAllContactsFromDBValue:
        [[ExtSdkContactManagerWrapper getInstance] getAllContactsFromDB:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAddUserToBlockListValue:
        [[ExtSdkContactManagerWrapper getInstance] addUserToBlockList:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRemoveUserFromBlockListValue:
        [[ExtSdkContactManagerWrapper getInstance] removeUserFromBlockList:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetBlockListFromServerValue:
        [[ExtSdkContactManagerWrapper getInstance] getBlockListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetBlockListFromDBValue:
        [[ExtSdkContactManagerWrapper getInstance] getBlockListFromDB:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAcceptInvitationValue:
        [[ExtSdkContactManagerWrapper getInstance] acceptInvitation:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDeclineInvitationValue:
        [[ExtSdkContactManagerWrapper getInstance] declineInvitation:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetSelfIdsOnOtherPlatformValue:
        [[ExtSdkContactManagerWrapper getInstance] getSelfIdsOnOtherPlatform:ps withMethodType:methodType result:callback];
        break;

    /// #pragma mark - EMContactDelegate value
    case ExtSdkMethodKeyOnContactChangedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

    /// #pragma mark - EMChatManagerWrapper value
    case ExtSdkMethodKeySendMessageValue:
        [[ExtSdkChatManagerWrapper getInstance] sendMessage:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyResendMessageValue:
        [[ExtSdkChatManagerWrapper getInstance] resendMessage:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAckMessageReadValue:
        [[ExtSdkChatManagerWrapper getInstance] ackMessageRead:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAckGroupMessageReadValue:
        [[ExtSdkChatManagerWrapper getInstance] ackGroupMessageRead:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAckConversationReadValue:
        [[ExtSdkChatManagerWrapper getInstance] ackConversationRead:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRecallMessageValue:
        [[ExtSdkChatManagerWrapper getInstance] recallMessage:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetConversationValue:
        [[ExtSdkChatManagerWrapper getInstance] getConversation:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyMarkAllChatMsgAsReadValue:
        [[ExtSdkChatManagerWrapper getInstance] markAllMessagesAsRead:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetUnreadMessageCountValue:
        [[ExtSdkChatManagerWrapper getInstance] getUnreadMessageCount:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateChatMessageValue:
        [[ExtSdkChatManagerWrapper getInstance] updateChatMessage:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDownloadAttachmentValue:
        [[ExtSdkChatManagerWrapper getInstance] downloadAttachment:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDownloadThumbnailValue:
        [[ExtSdkChatManagerWrapper getInstance] downloadThumbnail:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyImportMessagesValue:
        [[ExtSdkChatManagerWrapper getInstance] importMessages:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoadAllConversationsValue:
        [[ExtSdkChatManagerWrapper getInstance] loadAllConversations:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetConversationsFromServerValue:
        [[ExtSdkChatManagerWrapper getInstance] getConversationsFromServer:ps withMethodType:methodType result:callback];
        break;

    case ExtSdkMethodKeyDeleteConversationValue:
        [[ExtSdkChatManagerWrapper getInstance] deleteConversation:ps withMethodType:methodType result:callback];
        break;
//    case ExtSdkMethodKeySetVoiceMessageListenedValue:
//        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
//        break;
//    case ExtSdkMethodKeyUpdateParticipantValue:
//        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
//        break;
    case ExtSdkMethodKeyUpdateConversationsNameValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyFetchHistoryMessagesValue:
        [[ExtSdkChatManagerWrapper getInstance] fetchHistoryMessages:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeySearchChatMsgFromDBValue:
        [[ExtSdkChatManagerWrapper getInstance] searchChatMsgFromDB:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetMessageValue:
        [[ExtSdkChatManagerWrapper getInstance] getMessageWithMessageId:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAsyncFetchGroupAcksValue:
        [[ExtSdkChatManagerWrapper getInstance] fetchGroupReadAck:ps withMethodType:methodType result:callback];
        break;

    /// #pragma mark - EMChatManagerDelegate value
    case ExtSdkMethodKeyOnMessagesReceivedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnCmdMessagesReceivedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessagesReadValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnGroupMessageReadValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessagesDeliveredValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessagesRecalledValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

    case ExtSdkMethodKeyOnConversationUpdateValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnConversationHasReadValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

    /// #pragma mark - EMMessageListener value
    case ExtSdkMethodKeyOnMessageProgressUpdateValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessageSuccessValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessageErrorValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessageReadAckValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessageDeliveryAckValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyOnMessageStatusChangedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

        /// #pragma mark - EMConversationWrapper value

    case ExtSdkMethodKeyGetUnreadMsgCountValue:
        [[ExtSdkConversationWrapper getInstance] getUnreadMsgCount:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyMarkAllMsgsAsReadValue:
        [[ExtSdkConversationWrapper getInstance] markAllMsgsAsRead:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyMarkMsgAsReadValue:
        [[ExtSdkConversationWrapper getInstance] markMsgAsRead:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeySyncConversationExtValue:
        [[ExtSdkConversationWrapper getInstance] syncConversationExt:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeySyncConversationNameValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyRemoveMsgValue:
        [[ExtSdkConversationWrapper getInstance] removeMsg:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetLatestMsgValue:
        [[ExtSdkConversationWrapper getInstance] getLatestMsg:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetLatestMsgFromOthersValue:
        [[ExtSdkConversationWrapper getInstance] getLatestMsgFromOthers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyClearAllMsgValue:
        [[ExtSdkConversationWrapper getInstance] clearAllMsg:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyInsertMsgValue:
        [[ExtSdkConversationWrapper getInstance] insertMsg:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAppendMsgValue:
        [[ExtSdkConversationWrapper getInstance] appendMsg:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateConversationMsgValue:
        [[ExtSdkConversationWrapper getInstance] updateConversationMsg:ps withMethodType:methodType result:callback];
        break;

    case ExtSdkMethodKeyLoadMsgWithIdValue:
        [[ExtSdkConversationWrapper getInstance] loadMsgWithId:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoadMsgWithStartIdValue:
        [[ExtSdkConversationWrapper getInstance] loadMsgWithStartId:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoadMsgWithKeywordsValue:
        [[ExtSdkConversationWrapper getInstance] loadMsgWithKeywords:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoadMsgWithMsgTypeValue:
        [[ExtSdkConversationWrapper getInstance] loadMsgWithMsgType:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLoadMsgWithTimeValue:
        [[ExtSdkConversationWrapper getInstance] loadMsgWithTime:ps withMethodType:methodType result:callback];
        break;

        /// #pragma mark - EMChatroomManagerWrapper value

    case ExtSdkMethodKeyJoinChatRoomValue:
        [[ExtSdkChatroomManagerWrapper getInstance] joinChatRoom:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLeaveChatRoomValue:
        [[ExtSdkChatroomManagerWrapper getInstance] leaveChatRoom:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetChatroomsFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] getChatroomsFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchChatRoomFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] fetchChatroomFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetChatRoomValue:
        [[ExtSdkChatroomManagerWrapper getInstance] getChatRoom:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetAllChatRoomsValue:
        [[ExtSdkChatroomManagerWrapper getInstance] getAllChatRooms:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyCreateChatRoomValue:
        [[ExtSdkChatroomManagerWrapper getInstance] createChatRoom:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDestroyChatRoomValue:
        [[ExtSdkChatroomManagerWrapper getInstance] destroyChatRoom:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomUpdateSubjectValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomUpdateSubject:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomUpdateDescriptionValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomUpdateDescription:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetChatroomMemberListFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] getChatroomMemberListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomMuteMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomMuteMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomUnmuteMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomUnmuteMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChangeChatRoomOwnerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] changeChatRoomOwner:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomAddAdminValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomAddAdmin:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomRemoveAdminValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomRemoveAdmin:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetChatroomMuteListFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] getChatroomMuteListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomRemoveMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomRemoveMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomBlockMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomBlockMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyChatRoomUnblockMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] chatRoomUnblockMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchChatroomBlockListFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] fetchChatroomBlockListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateChatRoomAnnouncementValue:
        [[ExtSdkChatroomManagerWrapper getInstance] updateChatRoomAnnouncement:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchChatroomAnnouncementValue:
        [[ExtSdkChatroomManagerWrapper getInstance] fetchChatroomAnnouncement:ps withMethodType:methodType result:callback];
        break;

    case ExtSdkMethodKeyAddMembersToChatRoomWhiteListValue:
        [[ExtSdkChatroomManagerWrapper getInstance] addMembersToChatRoomWhiteList:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRemoveMembersFromChatRoomWhiteListValue:
        [[ExtSdkChatroomManagerWrapper getInstance] removeMembersFromChatRoomWhiteList:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchChatRoomWhiteListFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] fetchChatRoomWhiteListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyIsMemberInChatRoomWhiteListFromServerValue:
        [[ExtSdkChatroomManagerWrapper getInstance] isMemberInChatRoomWhiteListFromServer:ps withMethodType:methodType result:callback];
        break;

    case ExtSdkMethodKeyMuteAllChatRoomMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] muteAllChatRoomMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUnMuteAllChatRoomMembersValue:
        [[ExtSdkChatroomManagerWrapper getInstance] unMuteAllChatRoomMembers:ps withMethodType:methodType result:callback];
        break;

    /// #pragma mark - EMChatroomManagerDelegate value
    case ExtSdkMethodKeyChatroomChangedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

        /// #pragma mark - EMGroupManagerWrapper value

    case ExtSdkMethodKeyGetGroupWithIdValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupWithId:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetJoinedGroupsValue:
        [[ExtSdkGroupManagerWrapper getInstance] getJoinedGroups:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupsWithoutPushNotificationValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupsWithoutPushNotification:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetJoinedGroupsFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getJoinedGroupsFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetPublicGroupsFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getPublicGroupsFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyCreateGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] createGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupSpecificationFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupSpecificationFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupMemberListFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupMemberListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupBlockListFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupBlockListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupMuteListFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupMuteListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupWhiteListFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupWhiteListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyIsMemberInWhiteListFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] isMemberInWhiteListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupFileListFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupFileListFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetGroupAnnouncementFromServerValue:
        [[ExtSdkGroupManagerWrapper getInstance] getGroupAnnouncementFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAddMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] addMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyInviterUserValue:
        [[ExtSdkGroupManagerWrapper getInstance] inviterUser:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRemoveMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] removeMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyBlockMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] blockMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUnblockMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] unblockMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateGroupSubjectValue:
        [[ExtSdkGroupManagerWrapper getInstance] updateGroupSubject:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateDescriptionValue:
        [[ExtSdkGroupManagerWrapper getInstance] updateDescription:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyLeaveGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] leaveGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDestroyGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] destroyGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyBlockGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] blockGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUnblockGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] unblockGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateGroupOwnerValue:
        [[ExtSdkGroupManagerWrapper getInstance] updateGroupOwner:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAddAdminValue:
        [[ExtSdkGroupManagerWrapper getInstance] addAdmin:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRemoveAdminValue:
        [[ExtSdkGroupManagerWrapper getInstance] removeAdmin:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyMuteMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] muteMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUnMuteMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] unMuteMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyMuteAllMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] muteAllMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUnMuteAllMembersValue:
        [[ExtSdkGroupManagerWrapper getInstance] unMuteAllMembers:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAddWhiteListValue:
        [[ExtSdkGroupManagerWrapper getInstance] addWhiteList:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRemoveWhiteListValue:
        [[ExtSdkGroupManagerWrapper getInstance] removeWhiteList:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUploadGroupSharedFileValue:
        [[ExtSdkGroupManagerWrapper getInstance] uploadGroupSharedFile:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDownloadGroupSharedFileValue:
        [[ExtSdkGroupManagerWrapper getInstance] downloadGroupSharedFile:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRemoveGroupSharedFileValue:
        [[ExtSdkGroupManagerWrapper getInstance] removeGroupSharedFile:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateGroupAnnouncementValue:
        [[ExtSdkGroupManagerWrapper getInstance] updateGroupAnnouncement:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateGroupExtValue:
        [[ExtSdkGroupManagerWrapper getInstance] updateGroupExt:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyJoinPublicGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] joinPublicGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyRequestToJoinPublicGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] requestToJoinPublicGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAcceptJoinApplicationValue:
        [[ExtSdkGroupManagerWrapper getInstance] acceptJoinApplication:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDeclineJoinApplicationValue:
        [[ExtSdkGroupManagerWrapper getInstance] declineJoinApplication:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyAcceptInvitationFromGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] acceptInvitationFromGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDeclineInvitationFromGroupValue:
        [[ExtSdkGroupManagerWrapper getInstance] declineInvitationFromGroup:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyIgnoreGroupPushValue:
        [[ExtSdkGroupManagerWrapper getInstance] ignoreGroupPush:ps withMethodType:methodType result:callback];
        break;

    /// #pragma mark - ExtSdkGroupManagerDelegate
    case ExtSdkMethodKeyOnGroupChangedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;

    /// #pragma mark - EMPushManagerWrapper value
    case ExtSdkMethodKeyGetImPushConfigValue:
        [[ExtSdkPushManagerWrapper getInstance] getImPushConfig:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetImPushConfigFromServerValue:
        [[ExtSdkPushManagerWrapper getInstance] getImPushConfigFromServer:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdatePushNicknameValue:
        [[ExtSdkPushManagerWrapper getInstance] updatePushNickname:ps withMethodType:methodType result:callback];
        break;

    case ExtSdkMethodKeyImPushNoDisturbValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyUpdateImPushStyleValue:
        [[ExtSdkPushManagerWrapper getInstance] updateImPushStyle:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateGroupPushServiceValue:
        [[ExtSdkPushManagerWrapper getInstance] updateGroupPushService:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetNoDisturbGroupsValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyBindDeviceTokenValue:
        [[ExtSdkPushManagerWrapper getInstance] bindDeviceToken:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyEnablePushValue:
        [[ExtSdkPushManagerWrapper getInstance] enablePush:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyDisablePushValue:
        [[ExtSdkPushManagerWrapper getInstance] disablePush:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetNoPushGroupsValue:
        [[ExtSdkPushManagerWrapper getInstance] getNoPushGroups:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeySetNoDisturbUsersValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyGetNoDisturbUsersFromServerValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyUpdateUserPushServiceValue:
        [[ExtSdkPushManagerWrapper getInstance] updateUserPushService:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyGetNoPushUsersValue:
        [[ExtSdkPushManagerWrapper getInstance] getNoPushUsers:ps withMethodType:methodType result:callback];
        break;

    /// #pragma mark - EMUserInfoManagerWrapper value
    case ExtSdkMethodKeyUpdateOwnUserInfoValue:
        [[ExtSdkUserInfoManagerWrapper getInstance] updateOwnUserInfo:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyUpdateOwnUserInfoWithTypeValue:
        [[ExtSdkUserInfoManagerWrapper getInstance] updateOwnUserInfoWithType:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchUserInfoByIdValue:
        [[ExtSdkUserInfoManagerWrapper getInstance] fetchUserInfoById:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchUserInfoByIdWithTypeValue:
        [[ExtSdkUserInfoManagerWrapper getInstance] fetchUserInfoByIdWithType:ps withMethodType:methodType result:callback];
        break;

    case ExtSdkMethodKeyTranslateMessageValue:
        [[ExtSdkChatManagerWrapper getInstance] translateMessage:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchSupportedLanguagesValue:
        [[ExtSdkChatManagerWrapper getInstance] fetchSupportLanguages:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyOnPresenceStatusChangedValue:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    case ExtSdkMethodKeyPublishPresenceWithDescriptionValue:
        [[ExtSdkPresenceManagerWrapper getInstance] fetchPresenceStatus:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyPresenceSubscribeValue:
        [[ExtSdkPresenceManagerWrapper getInstance] subscribe:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyPresenceUnsubscribeValue:
        [[ExtSdkPresenceManagerWrapper getInstance] unsubscribe:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchSubscribedMembersWithPageNumValue:
        [[ExtSdkPresenceManagerWrapper getInstance] fetchSubscribedMembersWithPageNum:ps withMethodType:methodType result:callback];
        break;
    case ExtSdkMethodKeyFetchPresenceStatusValue:
        [[ExtSdkPresenceManagerWrapper getInstance] fetchPresenceStatus:ps withMethodType:methodType result:callback];
        break;

    default:
        [callback onFail:1 withExtension:[NSString stringWithFormat:@"not implement: %@", methodType]];
        break;
    }
}

- (void)delListener:(nonnull id<ExtSdkDelegateObjc>)listener {
    NSLog(@"%@: delListener:", TAG);
}

- (void)init:(nonnull id<NSObject>)config {
    NSLog(@"%@: init:", TAG);
}

- (void)unInit:(nullable id<NSObject>)params {
    NSLog(@"%@: unInit:", TAG);
}

- (void)onReceive:(nonnull NSString *)methodType withParams:(nullable NSObject *)params {
    NSLog(@"%@: onReceive: %@: %@", TAG, methodType, nil != params ? params : @"");
    [_listener onReceive:methodType withParams:params];
}

@end
