commit
2a7d7ee29b
@ -9,7 +9,6 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||||
import io.flutter.plugin.common.EventChannel;
|
|
||||||
import io.flutter.plugin.common.MethodCall;
|
import io.flutter.plugin.common.MethodCall;
|
||||||
import io.flutter.plugin.common.MethodChannel;
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||||
|
@ -11,9 +11,9 @@ public class AdvancedMsgListenerImpl implements OnAdvancedMsgListener {
|
|||||||
final MethodChannel channel;
|
final MethodChannel channel;
|
||||||
final Map<String, String> values = new HashMap<>();
|
final Map<String, String> values = new HashMap<>();
|
||||||
|
|
||||||
public AdvancedMsgListenerImpl(MethodChannel channel, String id) {
|
public AdvancedMsgListenerImpl(MethodChannel channel, String listenerId) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.values.put("id", id);
|
this.values.put("id", listenerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,10 +8,10 @@ import io.flutter.plugin.common.MethodChannel;
|
|||||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||||
import open_im_sdk.SendMsgCallBack;
|
import open_im_sdk.SendMsgCallBack;
|
||||||
|
|
||||||
public class SendMsgProgressListener implements SendMsgCallBack {
|
public class MsgSendProgressListener implements SendMsgCallBack {
|
||||||
|
|
||||||
|
|
||||||
public SendMsgProgressListener(MethodChannel.Result result, MethodChannel channel, MethodCall call) {
|
public MsgSendProgressListener(MethodChannel.Result result, MethodChannel channel, MethodCall call) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.call = call;
|
this.call = call;
|
||||||
@ -25,13 +25,11 @@ public class SendMsgProgressListener implements SendMsgCallBack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(long l, String s) {
|
public void onError(long l, String s) {
|
||||||
System.out.println("=================onError============" + s);
|
|
||||||
CommonUtil.runMainThreadReturnError(result, l, s, null);
|
CommonUtil.runMainThreadReturnError(result, l, s, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgress(long l) {
|
public void onProgress(long l) {
|
||||||
System.out.println("================onProgress============" + l);
|
|
||||||
values.put("clientMsgID", CommonUtil.getSendMessageClientMsgID(call));
|
values.put("clientMsgID", CommonUtil.getSendMessageClientMsgID(call));
|
||||||
values.put("progress", l);
|
values.put("progress", l);
|
||||||
CommonUtil.emitEvent(channel, "messageProgressListener", "onProgress", values);
|
CommonUtil.emitEvent(channel, "messageProgressListener", "onProgress", values);
|
||||||
@ -39,7 +37,6 @@ public class SendMsgProgressListener implements SendMsgCallBack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String s) {
|
public void onSuccess(String s) {
|
||||||
System.out.println("=================onSuccess============" + s);
|
|
||||||
CommonUtil.runMainThreadReturn(result, s);
|
CommonUtil.runMainThreadReturn(result, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,13 +17,13 @@ public class ConversationManager {
|
|||||||
public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) {
|
public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.setConversationListener(new ConversationListenerImpl(channel));
|
Open_im_sdk.setConversationListener(new ConversationListenerImpl(channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) {
|
public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.getAllConversationList(new BaseImpl(result));
|
Open_im_sdk.getAllConversationList(new BaseImpl(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
|
public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.getOneConversation(CommonUtil.getConversationId(methodCall), new BaseImpl(result));
|
Open_im_sdk.getOneConversation(CommonUtil.getConversationSourceId(methodCall), CommonUtil.getConversationSessionType(methodCall), new BaseImpl(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) {
|
public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
|
@ -20,7 +20,7 @@ public class FriendshipManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) {
|
public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.getFriendsInfo(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
Open_im_sdk.getFriendsInfo(new BaseImpl(result), CommonUtil.getUidList(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFriend(MethodCall methodCall, MethodChannel.Result result) {
|
public void addFriend(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
@ -40,7 +40,7 @@ public class FriendshipManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) {
|
public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.addToBlackList(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
Open_im_sdk.addToBlackList(new BaseImpl(result), CommonUtil.getJsonUid(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getBlackList(MethodCall methodCall, MethodChannel.Result result) {
|
public void getBlackList(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
@ -48,23 +48,23 @@ public class FriendshipManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) {
|
public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.deleteFromBlackList(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
Open_im_sdk.deleteFromBlackList(new BaseImpl(result), CommonUtil.getJsonUid(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFriend(MethodCall methodCall, MethodChannel.Result result) {
|
public void checkFriend(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.checkFriend(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
Open_im_sdk.checkFriend(new BaseImpl(result), CommonUtil.getUidList(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFromFriendList(MethodCall methodCall, MethodChannel.Result result) {
|
public void deleteFromFriendList(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.deleteFromFriendList(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result));
|
Open_im_sdk.deleteFromFriendList(CommonUtil.getJsonUid(methodCall), new BaseImpl(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
|
public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.acceptFriendApplication(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
Open_im_sdk.acceptFriendApplication(new BaseImpl(result), CommonUtil.getJsonUid(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
|
public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.refuseFriendApplication(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
Open_im_sdk.refuseFriendApplication(new BaseImpl(result), CommonUtil.getJsonUid(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
|
public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
|
@ -37,7 +37,7 @@ public class IMManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) {
|
public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.getUsersInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result));
|
Open_im_sdk.getUsersInfo(CommonUtil.getUidList(methodCall), new BaseImpl(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) {
|
public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
|
@ -7,7 +7,7 @@ import io.flutter.plugin.common.MethodCall;
|
|||||||
import io.flutter.plugin.common.MethodChannel;
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
import io.openim.flutter_openim_sdk.listener.AdvancedMsgListenerImpl;
|
import io.openim.flutter_openim_sdk.listener.AdvancedMsgListenerImpl;
|
||||||
import io.openim.flutter_openim_sdk.listener.BaseImpl;
|
import io.openim.flutter_openim_sdk.listener.BaseImpl;
|
||||||
import io.openim.flutter_openim_sdk.listener.SendMsgProgressListener;
|
import io.openim.flutter_openim_sdk.listener.MsgSendProgressListener;
|
||||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||||
import open_im_sdk.OnAdvancedMsgListener;
|
import open_im_sdk.OnAdvancedMsgListener;
|
||||||
import open_im_sdk.Open_im_sdk;
|
import open_im_sdk.Open_im_sdk;
|
||||||
@ -29,7 +29,6 @@ public class MessageManager {
|
|||||||
AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(channel, key);
|
AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(channel, key);
|
||||||
listeners.put(methodCall.argument(KEY_ID), listener);
|
listeners.put(methodCall.argument(KEY_ID), listener);
|
||||||
Open_im_sdk.addAdvancedMsgListener(listener);
|
Open_im_sdk.addAdvancedMsgListener(listener);
|
||||||
System.out.println("=================add msg listener======" + listener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,12 +36,10 @@ public class MessageManager {
|
|||||||
String key = methodCall.argument(KEY_ID);
|
String key = methodCall.argument(KEY_ID);
|
||||||
OnAdvancedMsgListener listener = listeners.remove(key);
|
OnAdvancedMsgListener listener = listeners.remove(key);
|
||||||
Open_im_sdk.removeAdvancedMsgListener(listener);
|
Open_im_sdk.removeAdvancedMsgListener(listener);
|
||||||
System.out.println("=================remove msg listener======" + listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
|
public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
SendMsgProgressListener listener = new SendMsgProgressListener(result, channel, methodCall);
|
MsgSendProgressListener listener = new MsgSendProgressListener(result, channel, methodCall);
|
||||||
System.out.println("===============sendMessage===============");
|
|
||||||
Open_im_sdk.sendMessage(listener, CommonUtil.getSendMessageContent(methodCall), CommonUtil.getSendMessageReceiver(methodCall), CommonUtil.geSendMessageGroupId(methodCall), CommonUtil.getSendMessageOnlineOnly(methodCall));
|
Open_im_sdk.sendMessage(listener, CommonUtil.getSendMessageContent(methodCall), CommonUtil.getSendMessageReceiver(methodCall), CommonUtil.geSendMessageGroupId(methodCall), CommonUtil.getSendMessageOnlineOnly(methodCall));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,6 @@ import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin;
|
|||||||
|
|
||||||
|
|
||||||
public class CommonUtil {
|
public class CommonUtil {
|
||||||
/**
|
|
||||||
* 主线程处理器
|
|
||||||
*/
|
|
||||||
private final static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
private final static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
public static <T> T getParamValue(MethodCall methodCall, String param) {
|
public static <T> T getParamValue(MethodCall methodCall, String param) {
|
||||||
@ -42,14 +39,7 @@ public class CommonUtil {
|
|||||||
MAIN_HANDLER.post(runnable);
|
MAIN_HANDLER.post(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 运行主线程返回错误结果执行
|
|
||||||
*
|
|
||||||
* @param result 返回结果对象
|
|
||||||
* @param errorCode 错误码
|
|
||||||
* @param errorMessage 错误信息
|
|
||||||
* @param errorDetails 错误内容
|
|
||||||
*/
|
|
||||||
public static void runMainThreadReturnError(final MethodChannel.Result result, final String errorCode, final String errorMessage, final Object errorDetails) {
|
public static void runMainThreadReturnError(final MethodChannel.Result result, final String errorCode, final String errorMessage, final Object errorDetails) {
|
||||||
MAIN_HANDLER.post(new Runnable() {
|
MAIN_HANDLER.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -63,33 +53,6 @@ public class CommonUtil {
|
|||||||
runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails);
|
runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
public static void returnError(final MethodChannel.Result result, int i, String s) {
|
|
||||||
HashMap<String, Object> err = new HashMap<String, Object>();
|
|
||||||
err.put("code", i);
|
|
||||||
err.put("desc", s);
|
|
||||||
result.success(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void returnError(final MethodChannel.Result result, int i, String s, HashMap<String, Object> data) {
|
|
||||||
HashMap<String, Object> err = new HashMap<String, Object>();
|
|
||||||
err.put("code", i);
|
|
||||||
err.put("desc", s);
|
|
||||||
err.put("data", data);
|
|
||||||
result.success(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> void returnSuccess(final MethodChannel.Result result, T data) {
|
|
||||||
HashMap<String, Object> succ = new HashMap<String, Object>();
|
|
||||||
succ.put("code", 0);
|
|
||||||
succ.put("desc", "ok");
|
|
||||||
succ.put("data", data);
|
|
||||||
result.success(succ);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
public static <T> void emitEvent(MethodChannel channel, String method, String type, Long errCode, String errMsg, T data) {
|
public static <T> void emitEvent(MethodChannel channel, String method, String type, Long errCode, String errMsg, T data) {
|
||||||
runMainThread(new Runnable() {
|
runMainThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -124,6 +87,10 @@ public class CommonUtil {
|
|||||||
return getParamValue(methodCall, KEY_LOGIN_UID);
|
return getParamValue(methodCall, KEY_LOGIN_UID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getJsonUid(MethodCall methodCall) {
|
||||||
|
return JsonUtil.toString(getParamValue(methodCall, KEY_LOGIN_UID));
|
||||||
|
}
|
||||||
|
|
||||||
public static String getToken(MethodCall methodCall) {
|
public static String getToken(MethodCall methodCall) {
|
||||||
return getParamValue(methodCall, KEY_LOGIN_TOKEN);
|
return getParamValue(methodCall, KEY_LOGIN_TOKEN);
|
||||||
}
|
}
|
||||||
@ -239,6 +206,14 @@ public class CommonUtil {
|
|||||||
return getSDKJsonParam(methodCall, KEY_CONVERSATION_IDS);
|
return getSDKJsonParam(methodCall, KEY_CONVERSATION_IDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getConversationSourceId(MethodCall methodCall) {
|
||||||
|
return getParamValue(methodCall, KEY_CONVERSATION_SOURCE_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getConversationSessionType(MethodCall methodCall) {
|
||||||
|
return getParamValue(methodCall, KEY_CONVERSATION_SESSION_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getConversationDraft(MethodCall methodCall) {
|
public static String getConversationDraft(MethodCall methodCall) {
|
||||||
return getParamValue(methodCall, KEY_CONVERSATION_DRAFT);
|
return getParamValue(methodCall, KEY_CONVERSATION_DRAFT);
|
||||||
}
|
}
|
||||||
@ -247,6 +222,11 @@ public class CommonUtil {
|
|||||||
return getParamValue(methodCall, KEY_CONVERSATION_PINNED);
|
return getParamValue(methodCall, KEY_CONVERSATION_PINNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUidList(MethodCall methodCall) {
|
||||||
|
return getSDKJsonParam(methodCall, KEY_USER_IDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//login
|
//login
|
||||||
final static String KEY_LOGIN_UID = "uid";
|
final static String KEY_LOGIN_UID = "uid";
|
||||||
final static String KEY_LOGIN_TOKEN = "token";
|
final static String KEY_LOGIN_TOKEN = "token";
|
||||||
@ -283,4 +263,8 @@ public class CommonUtil {
|
|||||||
final static String KEY_CONVERSATION_IDS = "conversationIDList";
|
final static String KEY_CONVERSATION_IDS = "conversationIDList";
|
||||||
final static String KEY_CONVERSATION_DRAFT = "draftText";
|
final static String KEY_CONVERSATION_DRAFT = "draftText";
|
||||||
final static String KEY_CONVERSATION_PINNED = "isPinned";
|
final static String KEY_CONVERSATION_PINNED = "isPinned";
|
||||||
|
final static String KEY_CONVERSATION_SOURCE_ID = "sourceID";
|
||||||
|
final static String KEY_CONVERSATION_SESSION_TYPE = "sessionType";
|
||||||
|
// user info
|
||||||
|
final static String KEY_USER_IDS = "uidList";
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
import 'package:flutter/services.dart';
|
export 'src/enum/listener_type.dart';
|
||||||
import 'package:flutter_openim_sdk/manager/im_manager.dart';
|
export 'src/enum/message_type.dart';
|
||||||
|
export 'src/listener/advanced_msg_listener.dart';
|
||||||
class FlutterOpenimSdk {
|
export 'src/listener/conversation_listener.dart';
|
||||||
static const MethodChannel _channel =
|
export 'src/listener/friendship_listener.dart';
|
||||||
const MethodChannel('flutter_openim_sdk');
|
export 'src/listener/init_sdk_listener.dart';
|
||||||
|
export 'src/listener/msg_send_progress_listener.dart';
|
||||||
static IMManager iMManager = IMManager(_channel);
|
export 'src/manager/im_conversation_manager.dart';
|
||||||
}
|
export 'src/manager/im_friendship_manager.dart';
|
||||||
|
export 'src/manager/im_group_manager.dart';
|
||||||
|
export 'src/manager/im_manager.dart';
|
||||||
|
export 'src/manager/im_message_manager.dart';
|
||||||
|
export 'src/manager/im_offline_push_manager.dart';
|
||||||
|
export 'src/manager/im_signaling_manager.dart';
|
||||||
|
export 'src/models/conversation_info.dart';
|
||||||
|
export 'src/models/message.dart';
|
||||||
|
export 'src/models/user_info.dart';
|
||||||
|
export 'src/openim.dart';
|
||||||
|
@ -1,36 +1,33 @@
|
|||||||
/// 事件监听类型
|
|
||||||
///
|
|
||||||
/// {@category Enums}
|
|
||||||
///
|
|
||||||
class ListenerType {
|
class ListenerType {
|
||||||
///简单监听
|
///
|
||||||
///
|
///
|
||||||
static const String simpleMsgListener = 'simpleMsgListener';
|
static const String simpleMsgListener = 'simpleMsgListener';
|
||||||
|
|
||||||
///初始化监听
|
///
|
||||||
///
|
///
|
||||||
static const String initSDKListener = 'initSDKListener';
|
static const String initSDKListener = 'initSDKListener';
|
||||||
|
|
||||||
///群组监听
|
///
|
||||||
///
|
///
|
||||||
static const String groupListener = 'groupListener';
|
static const String groupListener = 'groupListener';
|
||||||
|
|
||||||
///高级消息监听
|
///
|
||||||
///
|
///
|
||||||
static const String advancedMsgListener = 'advancedMsgListener';
|
static const String advancedMsgListener = 'advancedMsgListener';
|
||||||
|
|
||||||
///会话监听
|
///
|
||||||
///
|
///
|
||||||
static const String conversationListener = 'conversationListener';
|
static const String conversationListener = 'conversationListener';
|
||||||
|
|
||||||
///好友关系链监听
|
///
|
||||||
///
|
///
|
||||||
static const String friendListener = 'friendListener';
|
static const String friendListener = 'friendListener';
|
||||||
|
|
||||||
///信令监听
|
///
|
||||||
///
|
///
|
||||||
static const String signalingListener = 'signalingListener';
|
static const String signalingListener = 'signalingListener';
|
||||||
|
|
||||||
static const String messageProgressListener =
|
///
|
||||||
"messageProgressListener";
|
static const String msgSendProgressListener = "msgSendProgressListener";
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter_openim_sdk/models/message.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
|
||||||
|
|
||||||
class AdvancedMsgListener {
|
class AdvancedMsgListener {
|
||||||
/// listener uniquely identifies
|
/// listener uniquely identifies
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_openim_sdk/models/conversation_info.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
|
||||||
class ConversationListener {
|
class ConversationListener {
|
||||||
void onConversationChanged(List<ConversationInfo> list) {}
|
void onConversationChanged(List<ConversationInfo> list) {}
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_openim_sdk/models/user_info.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
|
||||||
class InitSDKListener {
|
class InitSDKListener {
|
||||||
/// SDK 正在连接到服务器
|
/// SDK 正在连接到服务器
|
@ -1,8 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_openim_sdk/listener/conversation_listener.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
import 'package:flutter_openim_sdk/models/conversation_info.dart';
|
|
||||||
|
|
||||||
class ConversationManager {
|
class ConversationManager {
|
||||||
MethodChannel _channel;
|
MethodChannel _channel;
|
||||||
@ -21,17 +20,17 @@ class ConversationManager {
|
|||||||
.then((value) => _toList(value));
|
.then((value) => _toList(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// sourceID 若为单聊则为userID,若为群聊则为groupID
|
||||||
|
/// sessionType 若为单聊则为1,若为群聊则为2
|
||||||
Future<ConversationInfo> getSingleConversation(
|
Future<ConversationInfo> getSingleConversation(
|
||||||
{required String conversationID}) {
|
{required String sourceID, required String sessionType}) {
|
||||||
return _channel
|
return _channel
|
||||||
.invokeMethod(
|
.invokeMethod('getOneConversation',
|
||||||
'getOneConversation',
|
_buildParam({"sourceID": sourceID, "sessionType": sessionType}))
|
||||||
_buildParam({
|
|
||||||
"conversationID": conversationID,
|
|
||||||
}))
|
|
||||||
.then((value) => _toObj(value));
|
.then((value) => _toObj(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ["single_1234","group_3434"]
|
||||||
Future<List<ConversationInfo>> getMultipleConversation(
|
Future<List<ConversationInfo>> getMultipleConversation(
|
||||||
{required List<String> conversationIDList}) {
|
{required List<String> conversationIDList}) {
|
||||||
return _channel
|
return _channel
|
||||||
@ -71,7 +70,6 @@ class ConversationManager {
|
|||||||
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static Map _buildParam(Map param) {
|
static Map _buildParam(Map param) {
|
||||||
param["ManagerName"] = "conversationManager";
|
param["ManagerName"] = "conversationManager";
|
||||||
return param;
|
return param;
|
||||||
@ -86,7 +84,6 @@ class ConversationManager {
|
|||||||
static ConversationInfo _toObj(String value) =>
|
static ConversationInfo _toObj(String value) =>
|
||||||
ConversationInfo.fromJson(_formatJson(value));
|
ConversationInfo.fromJson(_formatJson(value));
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static dynamic _formatJson(value) {
|
static dynamic _formatJson(value) {
|
||||||
return jsonDecode(_printValue(value));
|
return jsonDecode(_printValue(value));
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_openim_sdk/listener/friendship_listener.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
import 'package:flutter_openim_sdk/models/user_info.dart';
|
|
||||||
|
|
||||||
class FriendshipManager {
|
class FriendshipManager {
|
||||||
MethodChannel _channel;
|
MethodChannel _channel;
|
||||||
@ -90,7 +89,6 @@ class FriendshipManager {
|
|||||||
return _channel.invokeMethod('forceSyncBlackList', _buildParam({}));
|
return _channel.invokeMethod('forceSyncBlackList', _buildParam({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static Map _buildParam(Map param) {
|
static Map _buildParam(Map param) {
|
||||||
param["ManagerName"] = "friendshipManager";
|
param["ManagerName"] = "friendshipManager";
|
||||||
return param;
|
return param;
|
||||||
@ -104,7 +102,6 @@ class FriendshipManager {
|
|||||||
|
|
||||||
static UserInfo _toObj(String value) => UserInfo.fromJson(_formatJson(value));
|
static UserInfo _toObj(String value) => UserInfo.fromJson(_formatJson(value));
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static dynamic _formatJson(value) {
|
static dynamic _formatJson(value) {
|
||||||
return jsonDecode(_printValue(value));
|
return jsonDecode(_printValue(value));
|
||||||
}
|
}
|
@ -1,18 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_openim_sdk/enum/listener_type.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
import 'package:flutter_openim_sdk/listener/int_sdk_listener.dart';
|
|
||||||
import 'package:flutter_openim_sdk/manager/im_conversation_manager.dart';
|
|
||||||
import 'package:flutter_openim_sdk/manager/im_friendship_manager.dart';
|
|
||||||
import 'package:flutter_openim_sdk/manager/im_group_manager.dart';
|
|
||||||
import 'package:flutter_openim_sdk/manager/im_message_manager.dart';
|
|
||||||
import 'package:flutter_openim_sdk/manager/im_offline_push_manager.dart';
|
|
||||||
import 'package:flutter_openim_sdk/manager/im_signaling_manager.dart';
|
|
||||||
import 'package:flutter_openim_sdk/models/conversation_info.dart';
|
|
||||||
import 'package:flutter_openim_sdk/models/message.dart';
|
|
||||||
import 'package:flutter_openim_sdk/models/user_info.dart';
|
|
||||||
|
|
||||||
class IMManager {
|
class IMManager {
|
||||||
MethodChannel _channel;
|
MethodChannel _channel;
|
||||||
@ -37,21 +26,6 @@ class IMManager {
|
|||||||
void addNativeCallback(MethodChannel _channel) {
|
void addNativeCallback(MethodChannel _channel) {
|
||||||
_channel.setMethodCallHandler((call) {
|
_channel.setMethodCallHandler((call) {
|
||||||
try {
|
try {
|
||||||
/*if (call.method == ListenerType.simpleMsgListener) {
|
|
||||||
var args = call.arguments;
|
|
||||||
var data = args['data'];
|
|
||||||
String type = args['type'];
|
|
||||||
switch (type) {
|
|
||||||
case 'onRecvC2CCustomMessage':
|
|
||||||
break;
|
|
||||||
case 'onRecvC2CTextMessage':
|
|
||||||
break;
|
|
||||||
case 'onRecvGroupCustomMessage':
|
|
||||||
break;
|
|
||||||
case 'onRecvGroupTextMessage':
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else */
|
|
||||||
if (call.method == ListenerType.initSDKListener) {
|
if (call.method == ListenerType.initSDKListener) {
|
||||||
String type = call.arguments['type'];
|
String type = call.arguments['type'];
|
||||||
dynamic data = call.arguments['data'];
|
dynamic data = call.arguments['data'];
|
||||||
@ -150,7 +124,8 @@ class IMManager {
|
|||||||
} else if (call.method == ListenerType.advancedMsgListener) {
|
} else if (call.method == ListenerType.advancedMsgListener) {
|
||||||
var type = call.arguments['type'];
|
var type = call.arguments['type'];
|
||||||
var id = call.arguments['data']['id'];
|
var id = call.arguments['data']['id'];
|
||||||
var msg = Message.fromJson(_formatJson(call.arguments['data']['message']));
|
var msg =
|
||||||
|
Message.fromJson(_formatJson(call.arguments['data']['message']));
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'onRecvNewMessage':
|
case 'onRecvNewMessage':
|
||||||
for (var listener in messageManager.advancedMsgListeners) {
|
for (var listener in messageManager.advancedMsgListeners) {
|
||||||
@ -174,14 +149,13 @@ class IMManager {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (call.method == ListenerType.messageProgressListener) {
|
} else if (call.method == ListenerType.msgSendProgressListener) {
|
||||||
String type = call.arguments['type'];
|
String type = call.arguments['type'];
|
||||||
dynamic data = call.arguments['data'];
|
dynamic data = call.arguments['data'];
|
||||||
String msgID = data['clientMsgID'] ?? '';
|
String msgID = data['clientMsgID'] ?? '';
|
||||||
int progress = data['progress'] ?? 100;
|
int progress = data['progress'] ?? 100;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'onProgress':
|
case 'onProgress':
|
||||||
print('===========$msgID======$progress');
|
|
||||||
messageManager.msgSendProgressListener?.onProgress(
|
messageManager.msgSendProgressListener?.onProgress(
|
||||||
msgID,
|
msgID,
|
||||||
progress,
|
progress,
|
||||||
@ -227,8 +201,6 @@ class IMManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (call.method == ListenerType.friendListener) {
|
} else if (call.method == ListenerType.friendListener) {
|
||||||
// int errCode = call.arguments['errCode'];
|
|
||||||
// String errMsg = call.arguments['errMsg'];
|
|
||||||
String type = call.arguments['type'];
|
String type = call.arguments['type'];
|
||||||
dynamic data = call.arguments['data'];
|
dynamic data = call.arguments['data'];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -265,36 +237,6 @@ class IMManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*else if (call.method == 'logFromSwift') {
|
|
||||||
var data = call.arguments["data"];
|
|
||||||
var msg = call.arguments["msg"];
|
|
||||||
} else if (call.method == ListenerType.signalingListener) {
|
|
||||||
var args = call.arguments;
|
|
||||||
String type = args['type'];
|
|
||||||
Map<String, dynamic> params = args['data'];
|
|
||||||
String inviteID =
|
|
||||||
params['inviteID'] == null ? '' : params['inviteID'];
|
|
||||||
String inviter = params['inviter'] == null ? '' : params['inviter'];
|
|
||||||
String groupID = params['groupID'] == null ? '' : params['groupID'];
|
|
||||||
List<String>? inviteeList = params['inviteeList'] == null
|
|
||||||
? null
|
|
||||||
: List.from(params['inviteeList']);
|
|
||||||
String data = params['data'] == null ? '' : params['data'];
|
|
||||||
String invitee = params['invitee'] == null ? '' : params['invitee'];
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case 'onReceiveNewInvitation':
|
|
||||||
break;
|
|
||||||
case 'onInviteeAccepted':
|
|
||||||
break;
|
|
||||||
case 'onInviteeRejected':
|
|
||||||
break;
|
|
||||||
case 'onInvitationCancelled':
|
|
||||||
break;
|
|
||||||
case 'onInvitationTimeout':
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
print(
|
print(
|
||||||
"回调失败了,数据类型异常。$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}");
|
"回调失败了,数据类型异常。$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}");
|
||||||
@ -357,7 +299,6 @@ class IMManager {
|
|||||||
return _channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
|
return _channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
|
||||||
}
|
}
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static Map _buildParam(Map param) {
|
static Map _buildParam(Map param) {
|
||||||
param["ManagerName"] = "imManager";
|
param["ManagerName"] = "imManager";
|
||||||
return param;
|
return param;
|
||||||
@ -366,7 +307,6 @@ class IMManager {
|
|||||||
static List<UserInfo> _toList(String value) =>
|
static List<UserInfo> _toList(String value) =>
|
||||||
(_formatJson(value) as List).map((e) => UserInfo.fromJson(e)).toList();
|
(_formatJson(value) as List).map((e) => UserInfo.fromJson(e)).toList();
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static dynamic _formatJson(value) {
|
static dynamic _formatJson(value) {
|
||||||
return jsonDecode(_printValue(value));
|
return jsonDecode(_printValue(value));
|
||||||
}
|
}
|
@ -1,9 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_openim_sdk/listener/advanced_msg_listener.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
import 'package:flutter_openim_sdk/listener/msg_send_progress_listener.dart';
|
|
||||||
import 'package:flutter_openim_sdk/models/message.dart';
|
|
||||||
|
|
||||||
class MessageManager {
|
class MessageManager {
|
||||||
MethodChannel _channel;
|
MethodChannel _channel;
|
||||||
@ -24,7 +22,7 @@ class MessageManager {
|
|||||||
'removeAdvancedMsgListener', _buildParam({'id': listener.id}));
|
'removeAdvancedMsgListener', _buildParam({'id': listener.id}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMsgProgressListener(MsgSendProgressListener listener) {
|
void setMsgSendProgressListener(MsgSendProgressListener listener) {
|
||||||
msgSendProgressListener = listener;
|
msgSendProgressListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +72,8 @@ class MessageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deleteMessages({required List<Message> msgList}) {
|
void deleteMessages({required List<Message> msgList}) {
|
||||||
// _channel.invokeMethod('deleteMessages', _buildParam(msgList.toJson()));
|
_channel.invokeMethod('deleteMessages',
|
||||||
|
_buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertSingleMessageToLocalStorage({
|
void insertSingleMessageToLocalStorage({
|
||||||
@ -194,9 +193,7 @@ class MessageManager {
|
|||||||
.then((value) => _toObj(value));
|
.then((value) => _toObj(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static Map _buildParam(Map param) {
|
static Map _buildParam(Map param) {
|
||||||
print('param:$param');
|
|
||||||
param["ManagerName"] = "messageManager";
|
param["ManagerName"] = "messageManager";
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
@ -206,7 +203,6 @@ class MessageManager {
|
|||||||
|
|
||||||
static Message _toObj(String value) => Message.fromJson(_formatJson(value));
|
static Message _toObj(String value) => Message.fromJson(_formatJson(value));
|
||||||
|
|
||||||
///@nodoc
|
|
||||||
static dynamic _formatJson(value) {
|
static dynamic _formatJson(value) {
|
||||||
return jsonDecode(_printValue(value));
|
return jsonDecode(_printValue(value));
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter_openim_sdk/models/message.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
|
||||||
class ConversationInfo {
|
class ConversationInfo {
|
||||||
String conversationID;
|
String conversationID;
|
@ -109,16 +109,16 @@ class Message {
|
|||||||
data['ext'] = this.ext;
|
data['ext'] = this.ext;
|
||||||
data['sessionType'] = this.sessionType;
|
data['sessionType'] = this.sessionType;
|
||||||
if (this.pictureElem != null) {
|
if (this.pictureElem != null) {
|
||||||
data['pictureElem'] = this.pictureElem?.toJson();
|
data['pictureElem'] = this.pictureElem!.toJson();
|
||||||
}
|
}
|
||||||
if (this.soundElem != null) {
|
if (this.soundElem != null) {
|
||||||
data['soundElem'] = this.soundElem?.toJson();
|
data['soundElem'] = this.soundElem!.toJson();
|
||||||
}
|
}
|
||||||
if (this.videoElem != null) {
|
if (this.videoElem != null) {
|
||||||
data['videoElem'] = this.videoElem?.toJson();
|
data['videoElem'] = this.videoElem!.toJson();
|
||||||
}
|
}
|
||||||
if (this.fileElem != null) {
|
if (this.fileElem != null) {
|
||||||
data['fileElem'] = this.fileElem?.toJson();
|
data['fileElem'] = this.fileElem!.toJson();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ class Message {
|
|||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
// TODO: implement ==
|
// TODO: implement ==
|
||||||
if (other is Message) {
|
if (other is Message) {
|
||||||
return other.id == id;
|
return other._id == _id;
|
||||||
}
|
}
|
||||||
return super == other;
|
return super == other;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ class Message {
|
|||||||
// TODO: implement hashCode
|
// TODO: implement hashCode
|
||||||
int get hashCode => super.hashCode;
|
int get hashCode => super.hashCode;
|
||||||
|
|
||||||
String? get id =>
|
String? get _id =>
|
||||||
clientMsgID == null || clientMsgID!.isEmpty ? serverMsgID : clientMsgID;
|
clientMsgID == null || clientMsgID!.isEmpty ? serverMsgID : clientMsgID;
|
||||||
}
|
}
|
||||||
|
|
9
lib/src/openim.dart
Normal file
9
lib/src/openim.dart
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
|
||||||
|
class OpenIM {
|
||||||
|
static const MethodChannel _channel =
|
||||||
|
const MethodChannel('flutter_openim_sdk');
|
||||||
|
|
||||||
|
static IMManager iMManager = IMManager(_channel);
|
||||||
|
}
|
@ -1,6 +1,3 @@
|
|||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_openim_sdk/models/message.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -20,15 +17,14 @@ void main() {
|
|||||||
|
|
||||||
test('getPlatformVersion', () async {});*/
|
test('getPlatformVersion', () async {});*/
|
||||||
|
|
||||||
Message m1= new Message(clientMsgID: '1',content: 'c1');
|
Message m1 = new Message(clientMsgID: '1', content: 'c1');
|
||||||
Message m2= new Message(clientMsgID: '2',content: 'c2');
|
Message m2 = new Message(clientMsgID: '2', content: 'c2');
|
||||||
Message m3= new Message(clientMsgID: '3',content: 'c3');
|
Message m3 = new Message(clientMsgID: '3', content: 'c3');
|
||||||
Message m4= new Message(clientMsgID: '3',content: 'c4');
|
Message m4 = new Message(clientMsgID: '3', content: 'c4');
|
||||||
List list = List.of([m1,m2,m3]);
|
List list = List.of([m1, m2, m3]);
|
||||||
|
|
||||||
|
|
||||||
print(list.contains(m4));
|
print(list.contains(m4));
|
||||||
print(m1==m4);
|
print(m1 == m4);
|
||||||
print(m2==m4);
|
print(m2 == m4);
|
||||||
print(m3==m4);
|
print(m3 == m4);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user