You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
11 KiB
194 lines
11 KiB
import Foundation
|
|
import OpenIMCore
|
|
|
|
public class ConversationManager: BaseServiceManager {
|
|
|
|
public override func registerHandlers() {
|
|
super.registerHandlers()
|
|
self["setConversationListener"] = setConversationListener
|
|
self["getAllConversationList"] = getAllConversationList
|
|
self["getConversationListSplit"] = getConversationListSplit
|
|
self["getOneConversation"] = getOneConversation
|
|
self["getMultipleConversation"] = getMultipleConversation
|
|
self["setConversationDraft"] = setConversationDraft
|
|
self["pinConversation"] = pinConversation
|
|
self["hideConversation"] = hideConversation
|
|
self["markConversationMessageAsRead"] = markConversationMessageAsRead
|
|
self["getTotalUnreadMsgCount"] = getTotalUnreadMsgCount
|
|
self["getConversationIDBySessionType"] = getConversationIDBySessionType
|
|
self["setConversationRecvMessageOpt"] = setConversationRecvMessageOpt
|
|
self["getConversationRecvMessageOpt"] = getConversationRecvMessageOpt
|
|
self["setConversationPrivateChat"] = setConversationPrivateChat
|
|
self["clearConversationAndDeleteAllMsg"] = clearConversationAndDeleteAllMsg
|
|
self["deleteConversationAndDeleteAllMsg"] = deleteConversationAndDeleteAllMsg
|
|
self["resetConversationGroupAtType"] = resetConversationGroupAtType
|
|
self["getAtAllTag"] = getAtAllTag
|
|
self["setGlobalRecvMessageOpt"] = setGlobalRecvMessageOpt
|
|
self["setConversationBurnDuration"] = setConversationBurnDuration
|
|
self["setConversationIsMsgDestruct"] = setConversationIsMsgDestruct
|
|
self["setConversationMsgDestructTime"] = setConversationMsgDestructTime
|
|
self["hideAllConversations"] = hideAllConversations
|
|
self["searchConversation"] = searchConversation
|
|
self["setConversationEx"] = setConversationEx
|
|
self["changeInputStates"] = changeInputStates
|
|
self["getInputStates"] = getInputStates
|
|
}
|
|
|
|
func setConversationListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationListener(ConversationListener(channel: channel))
|
|
callBack(result)
|
|
}
|
|
|
|
func getAllConversationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetAllConversationList(BaseCallback(result: result), methodCall[string: "operationID"])
|
|
}
|
|
|
|
func getConversationListSplit(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetConversationListSplit(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[int: "offset"], methodCall[int: "count"])
|
|
}
|
|
|
|
func getOneConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetOneConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[int32: "sessionType"], methodCall[string: "sourceID"])
|
|
}
|
|
|
|
func getMultipleConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetMultipleConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "conversationIDList"])
|
|
}
|
|
|
|
func setConversationDraft(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationDraft(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[string: "draftText"])
|
|
}
|
|
|
|
func pinConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkPinConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[bool: "isPinned"])
|
|
}
|
|
|
|
func hideConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkHideConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"])
|
|
}
|
|
|
|
func markConversationMessageAsRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkMarkConversationMessageAsRead(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"])
|
|
}
|
|
|
|
func getTotalUnreadMsgCount(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetTotalUnreadMsgCount(BaseCallback(result: result), methodCall[string: "operationID"])
|
|
}
|
|
|
|
func getConversationIDBySessionType(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
let conversationID = Open_im_sdkGetConversationIDBySessionType( methodCall[string: "operationID"],methodCall[string: "sourceID"], methodCall[int: "sessionType"])
|
|
callBack(result, conversationID)
|
|
}
|
|
|
|
func setConversationRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationRecvMessageOpt(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[int: "status"])
|
|
}
|
|
|
|
func getConversationRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetConversationRecvMessageOpt(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "conversationIDList"])
|
|
}
|
|
|
|
func setConversationPrivateChat(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationPrivateChat(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"],methodCall[bool: "isPrivate"])
|
|
}
|
|
|
|
func clearConversationAndDeleteAllMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkClearConversationAndDeleteAllMsg(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"])
|
|
}
|
|
|
|
func deleteConversationAndDeleteAllMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkDeleteConversationAndDeleteAllMsg(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"])
|
|
}
|
|
|
|
func deleteAllConversationFromLocal(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
}
|
|
|
|
func resetConversationGroupAtType(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkResetConversationGroupAtType(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"])
|
|
}
|
|
|
|
func getAtAllTag(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
callBack(result, Open_im_sdkGetAtAllTag(methodCall[string: "operationID"]))
|
|
}
|
|
|
|
func setGlobalRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetGlobalRecvMessageOpt(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[int: "status"])
|
|
}
|
|
|
|
func setConversationBurnDuration(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationBurnDuration(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[int32: "burnDuration"])
|
|
}
|
|
|
|
func setConversationIsMsgDestruct(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationIsMsgDestruct(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[bool: "isMsgDestruct"])
|
|
}
|
|
|
|
func setConversationMsgDestructTime(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationMsgDestructTime(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[int64: "duration"])
|
|
}
|
|
|
|
func hideAllConversations(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkHideAllConversations(BaseCallback(result: result), methodCall[string: "operationID"])
|
|
}
|
|
|
|
func searchConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSearchConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "name"])
|
|
}
|
|
|
|
func setConversationEx(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkSetConversationEx(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[string: "ex"])
|
|
}
|
|
|
|
func changeInputStates(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkChangeInputStates(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[bool: "focus"])
|
|
}
|
|
|
|
func getInputStates(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
|
Open_im_sdkGetInputStates(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[string: "userID"])
|
|
}
|
|
}
|
|
|
|
|
|
public class ConversationListener: NSObject, Open_im_sdk_callbackOnConversationListenerProtocol {
|
|
|
|
public func onSyncServerProgress(_ progress: Int) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onSyncServerProgress", errCode: nil, errMsg: nil, data: progress)
|
|
}
|
|
|
|
|
|
private let channel:FlutterMethodChannel
|
|
|
|
init(channel:FlutterMethodChannel) {
|
|
self.channel = channel
|
|
}
|
|
|
|
public func onConversationChanged(_ conversationList: String?) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onConversationChanged", errCode: nil, errMsg: nil, data: conversationList)
|
|
}
|
|
|
|
public func onNewConversation(_ conversationList: String?) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onNewConversation", errCode: nil, errMsg: nil, data: conversationList)
|
|
}
|
|
|
|
public func onSyncServerFailed(_ reinstalled: Bool) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onSyncServerFailed", errCode: nil, errMsg: nil, data: reinstalled)
|
|
}
|
|
|
|
public func onSyncServerFinish(_ reinstalled: Bool) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onSyncServerFinish", errCode: nil, errMsg: nil, data: reinstalled)
|
|
}
|
|
|
|
public func onSyncServerStart(_ reinstalled: Bool) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onSyncServerStart", errCode: nil, errMsg: nil, data: reinstalled)
|
|
}
|
|
|
|
public func onTotalUnreadMessageCountChanged(_ totalUnreadCount: Int32) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onTotalUnreadMessageCountChanged", errCode: nil, errMsg: nil, data: totalUnreadCount)
|
|
}
|
|
|
|
public func onConversationUserInputStatusChanged(_ change: String?) {
|
|
CommonUtil.emitEvent(channel: channel, method: "conversationListener", type: "onConversationUserInputStatusChanged", errCode: nil, errMsg: nil, data: change)
|
|
}
|
|
}
|
|
|
|
|
|
|