add group fuc

main
hrxiang 4 years ago
parent 073b91ba99
commit 3acbacda6d
  1. 3
      android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java
  2. 4
      android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListener.java
  3. 4
      android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseListener.java
  4. 2
      android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListener.java
  5. 2
      android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListener.java
  6. 77
      android/src/main/java/io/openim/flutter_openim_sdk/listener/GroupListener.java
  7. 2
      android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListener.java
  8. 31
      android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java
  9. 30
      android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java
  10. 109
      android/src/main/java/io/openim/flutter_openim_sdk/manager/GroupManager.java
  11. 14
      android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java
  12. 77
      android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java
  13. 58
      android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java
  14. 6
      lib/flutter_openim_sdk.dart
  15. 4
      lib/src/enum/conversation_type.dart
  16. 5
      lib/src/enum/group_role.dart
  17. 2
      lib/src/enum/message_type.dart
  18. 36
      lib/src/listener/group_listener.dart
  19. 4
      lib/src/manager/im_conversation_manager.dart
  20. 48
      lib/src/manager/im_group_manager.dart
  21. 110
      lib/src/manager/im_manager.dart
  22. 5
      lib/src/manager/im_message_manager.dart
  23. 4
      lib/src/models/conversation_info.dart
  24. 10
      lib/src/models/group_info.dart
  25. 28
      lib/src/models/user_info.dart
  26. 2
      lib/src/openim.dart

@ -16,6 +16,7 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugin.common.MethodChannel.Result;
import io.openim.flutter_openim_sdk.manager.ConversationManager; import io.openim.flutter_openim_sdk.manager.ConversationManager;
import io.openim.flutter_openim_sdk.manager.FriendshipManager; import io.openim.flutter_openim_sdk.manager.FriendshipManager;
import io.openim.flutter_openim_sdk.manager.GroupManager;
import io.openim.flutter_openim_sdk.manager.IMManager; import io.openim.flutter_openim_sdk.manager.IMManager;
import io.openim.flutter_openim_sdk.manager.MessageManager; import io.openim.flutter_openim_sdk.manager.MessageManager;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
@ -35,6 +36,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler
private static FriendshipManager friendshipManager; private static FriendshipManager friendshipManager;
private static MessageManager messageManager; private static MessageManager messageManager;
private static ConversationManager conversationManager; private static ConversationManager conversationManager;
private static GroupManager groupManager;
public FlutterOpenimSdkPlugin() { public FlutterOpenimSdkPlugin() {
} }
@ -44,6 +46,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler
FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager(); FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager();
FlutterOpenimSdkPlugin.messageManager = new MessageManager(); FlutterOpenimSdkPlugin.messageManager = new MessageManager();
FlutterOpenimSdkPlugin.conversationManager = new ConversationManager(); FlutterOpenimSdkPlugin.conversationManager = new ConversationManager();
FlutterOpenimSdkPlugin.groupManager = new GroupManager();
} }
@Override @Override

@ -6,10 +6,10 @@ import java.util.Map;
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;
public class AdvancedMsgListenerImpl implements OnAdvancedMsgListener { public class AdvancedMsgListener implements OnAdvancedMsgListener {
final Map<String, String> values = new HashMap<>(); final Map<String, String> values = new HashMap<>();
public AdvancedMsgListenerImpl(String listenerId) { public AdvancedMsgListener(String listenerId) {
this.values.put("id", listenerId); this.values.put("id", listenerId);
} }

@ -6,11 +6,11 @@ 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.Base; import open_im_sdk.Base;
public class BaseImpl implements Base { public class BaseListener implements Base {
MethodChannel.Result result; MethodChannel.Result result;
public BaseImpl(MethodChannel.Result result) { public BaseListener(MethodChannel.Result result) {
this.result = result; this.result = result;
} }

@ -3,7 +3,7 @@ package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnConversationListener; import open_im_sdk.OnConversationListener;
public class ConversationListenerImpl implements OnConversationListener { public class ConversationListener implements OnConversationListener {
@Override @Override

@ -3,7 +3,7 @@ package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnFriendshipListener; import open_im_sdk.OnFriendshipListener;
public class FriendshipListenerImpl implements OnFriendshipListener { public class FriendshipListener implements OnFriendshipListener {
@Override @Override
public void onBlackListAdd(String s) { public void onBlackListAdd(String s) {

@ -0,0 +1,77 @@
package io.openim.flutter_openim_sdk.listener;
import java.util.HashMap;
import java.util.Map;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnGroupListener;
public class GroupListener implements OnGroupListener {
@Override
public void onApplicationProcessed(String s, String s1, int i, String s2) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("opUser", s1);
map.put("agreeOrReject", i);
map.put("opReason", s2);
CommonUtil.emitEvent("groupListener", "onApplicationProcessed", map);
}
@Override
public void onGroupCreated(String s) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
CommonUtil.emitEvent("groupListener", "onGroupCreated", map);
}
@Override
public void onGroupInfoChanged(String s, String s1) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("groupInfo", s1);
CommonUtil.emitEvent("groupListener", "onGroupInfoChanged", map);
}
@Override
public void onMemberEnter(String s, String s1) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("memberList", s1);
CommonUtil.emitEvent("groupListener", "onMemberEnter", map);
}
@Override
public void onMemberInvited(String s, String s1, String s2) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("opUser", s1);
map.put("memberList", s2);
CommonUtil.emitEvent("groupListener", "onMemberInvited", map);
}
@Override
public void onMemberKicked(String s, String s1, String s2) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("opUser", s1);
map.put("memberList", s2);
CommonUtil.emitEvent("groupListener", "onMemberKicked", map);
}
@Override
public void onMemberLeave(String s, String s1) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("member", s1);
CommonUtil.emitEvent("groupListener", "onMemberLeave", map);
}
@Override
public void onReceiveJoinApplication(String s, String s1, String s2) {
Map<String, Object> map = new HashMap<>();
map.put("groupId", s);
map.put("member", s1);
map.put("opReason", s2);
CommonUtil.emitEvent("groupListener", "onReceiveJoinApplication", map);
}
}

@ -4,7 +4,7 @@ package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.IMSDKListener; import open_im_sdk.IMSDKListener;
public class SDKListenerImpl implements IMSDKListener { public class SDKListener implements IMSDKListener {
@Override @Override
public void onConnectFailed(long l, String s) { public void onConnectFailed(long l, String s) {

@ -2,42 +2,53 @@ package io.openim.flutter_openim_sdk.manager;
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.openim.flutter_openim_sdk.listener.BaseImpl; import io.openim.flutter_openim_sdk.listener.BaseListener;
import io.openim.flutter_openim_sdk.listener.ConversationListenerImpl; import io.openim.flutter_openim_sdk.listener.ConversationListener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
public class ConversationManager { 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()); Open_im_sdk.setConversationListener(new ConversationListener());
} }
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 BaseListener(result));
} }
public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) { public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getOneConversation(CommonUtil.getConversationSourceId(methodCall), CommonUtil.getConversationSessionType(methodCall), new BaseImpl(result)); Open_im_sdk.getOneConversation(
CommonUtil.getConversationSourceId(methodCall),
CommonUtil.getConversationSessionType(methodCall),
new BaseListener(result));
} }
public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) { public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getMultipleConversation(CommonUtil.getConversationIds(methodCall), new BaseImpl(result)); Open_im_sdk.getMultipleConversation(
CommonUtil.getConversationIds(methodCall),
new BaseListener(result));
} }
public void deleteConversation(MethodCall methodCall, MethodChannel.Result result) { public void deleteConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteConversation(CommonUtil.getConversationId(methodCall), new BaseImpl(result)); Open_im_sdk.deleteConversation(CommonUtil.getConversationId(methodCall), new BaseListener(result));
} }
public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) { public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setConversationDraft(CommonUtil.getConversationId(methodCall), CommonUtil.getConversationDraft(methodCall), new BaseImpl(result)); Open_im_sdk.setConversationDraft(
CommonUtil.getConversationId(methodCall),
CommonUtil.getConversationDraft(methodCall),
new BaseListener(result));
} }
public void pinConversation(MethodCall methodCall, MethodChannel.Result result) { public void pinConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.pinConversation(CommonUtil.getConversationId(methodCall), CommonUtil.isPinnedConversation(methodCall), new BaseImpl(result)); Open_im_sdk.pinConversation(
CommonUtil.getConversationId(methodCall),
CommonUtil.isPinnedConversation(methodCall),
new BaseListener(result));
} }
public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) { public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getTotalUnreadMsgCount(new BaseImpl(result)); Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result));
} }
} }

@ -2,8 +2,8 @@ package io.openim.flutter_openim_sdk.manager;
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.openim.flutter_openim_sdk.listener.BaseImpl; import io.openim.flutter_openim_sdk.listener.BaseListener;
import io.openim.flutter_openim_sdk.listener.FriendshipListenerImpl; import io.openim.flutter_openim_sdk.listener.FriendshipListener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
@ -11,55 +11,55 @@ public class FriendshipManager {
public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) { public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setFriendListener(new FriendshipListenerImpl()); Open_im_sdk.setFriendListener(new FriendshipListener());
} }
public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) { public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getFriendsInfo(new BaseImpl(result), CommonUtil.getUidList(methodCall)); Open_im_sdk.getFriendsInfo(new BaseListener(result), CommonUtil.getUidList(methodCall));
} }
public void addFriend(MethodCall methodCall, MethodChannel.Result result) { public void addFriend(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.addFriend(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); Open_im_sdk.addFriend(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall));
} }
public void getFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) { public void getFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getFriendApplicationList(new BaseImpl(result)); Open_im_sdk.getFriendApplicationList(new BaseListener(result));
} }
public void getFriendList(MethodCall methodCall, MethodChannel.Result result) { public void getFriendList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getFriendList(new BaseImpl(result)); Open_im_sdk.getFriendList(new BaseListener(result));
} }
public void setFriendInfo(MethodCall methodCall, MethodChannel.Result result) { public void setFriendInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setFriendInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result)); Open_im_sdk.setFriendInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseListener(result));
} }
public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) { public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.addToBlackList(new BaseImpl(result), CommonUtil.getJsonUid(methodCall)); Open_im_sdk.addToBlackList(new BaseListener(result), CommonUtil.getJsonUid(methodCall));
} }
public void getBlackList(MethodCall methodCall, MethodChannel.Result result) { public void getBlackList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getBlackList(new BaseImpl(result)); Open_im_sdk.getBlackList(new BaseListener(result));
} }
public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) { public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteFromBlackList(new BaseImpl(result), CommonUtil.getJsonUid(methodCall)); Open_im_sdk.deleteFromBlackList(new BaseListener(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.getUidList(methodCall)); Open_im_sdk.checkFriend(new BaseListener(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.getJsonUid(methodCall), new BaseImpl(result)); Open_im_sdk.deleteFromFriendList(CommonUtil.getJsonUid(methodCall), new BaseListener(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.getJsonUid(methodCall)); Open_im_sdk.acceptFriendApplication(new BaseListener(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.getJsonUid(methodCall)); Open_im_sdk.refuseFriendApplication(new BaseListener(result), CommonUtil.getJsonUid(methodCall));
} }
public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) { public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) {

@ -1,6 +1,113 @@
package io.openim.flutter_openim_sdk.manager; package io.openim.flutter_openim_sdk.manager;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.BaseListener;
import io.openim.flutter_openim_sdk.listener.GroupListener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk;
public class GroupManager { public class GroupManager {
public void setGroupListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setGroupListener(new GroupListener());
}
public void inviteUserToGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.inviteUserToGroup(
CommonUtil.getGid(methodCall),
CommonUtil.getGroupOpReason(methodCall),
CommonUtil.getUidList(methodCall),
new BaseListener(result));
}
public void kickGroupMember(MethodCall methodCall, MethodChannel.Result result) {
System.out.println("gid:" + CommonUtil.getGid(methodCall));
System.out.println("reason:" + CommonUtil.getGroupOpReason(methodCall));
System.out.println("uidList:" + CommonUtil.getUidList(methodCall));
Open_im_sdk.kickGroupMember(
CommonUtil.getGid(methodCall),
CommonUtil.getGroupOpReason(methodCall),
CommonUtil.getUidList(methodCall),
new BaseListener(result));
}
public void getGroupMembersInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupMembersInfo(
CommonUtil.getGid(methodCall),
CommonUtil.getUidList(methodCall),
new BaseListener(result));
}
public void getGroupMemberList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupMemberList(
CommonUtil.getGid(methodCall),
CommonUtil.getGroupListFilter(methodCall),
CommonUtil.getGroupListNext(methodCall),
new BaseListener(result));
}
public void getJoinedGroupList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getJoinedGroupList(new BaseListener(result));
}
public void createGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.createGroup(
CommonUtil.getGroupInfo(methodCall),
CommonUtil.getGroupMemberRoleList(methodCall),
new BaseListener(result));
}
public void setGroupInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setGroupInfo(
CommonUtil.getGroupInfo(methodCall),
new BaseListener(result));
}
public void getGroupsInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupsInfo(
CommonUtil.getGidList(methodCall),
new BaseListener(result));
}
public void joinGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.joinGroup(
CommonUtil.getGid(methodCall),
CommonUtil.getGroupOpReason(methodCall),
new BaseListener(result));
}
public void quitGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.quitGroup(
CommonUtil.getGid(methodCall),
new BaseListener(result));
}
public void transferGroupOwner(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.transferGroupOwner(
CommonUtil.getGid(methodCall),
CommonUtil.getUid(methodCall),
new BaseListener(result));
}
public void getGroupApplicationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupApplicationList(new BaseListener(result));
}
public void acceptGroupApplication(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.acceptGroupApplication(
CommonUtil.getGroupApplicationInfo(methodCall),
CommonUtil.getGroupOpReason(methodCall),
new BaseListener(result));
}
public void refuseGroupApplication(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.refuseGroupApplication(
CommonUtil.getGroupApplicationInfo(methodCall),
CommonUtil.getGroupOpReason(methodCall),
new BaseListener(result));
} }
}

@ -2,24 +2,24 @@ package io.openim.flutter_openim_sdk.manager;
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.openim.flutter_openim_sdk.listener.BaseImpl; import io.openim.flutter_openim_sdk.listener.BaseListener;
import io.openim.flutter_openim_sdk.listener.SDKListenerImpl; import io.openim.flutter_openim_sdk.listener.SDKListener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
public class IMManager { public class IMManager {
public void initSDK(MethodCall methodCall, MethodChannel.Result result) { public void initSDK(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.initSDK(CommonUtil.getSDKJsonParam(methodCall), new SDKListenerImpl()); Open_im_sdk.initSDK(CommonUtil.getSDKJsonParam(methodCall), new SDKListener());
CommonUtil.runMainThreadReturn(result, null); CommonUtil.runMainThreadReturn(result, null);
} }
public void login(MethodCall methodCall, MethodChannel.Result result) { public void login(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.login(CommonUtil.getUid(methodCall), CommonUtil.getToken(methodCall), new BaseImpl(result)); Open_im_sdk.login(CommonUtil.getUid(methodCall), CommonUtil.getToken(methodCall), new BaseListener(result));
} }
public void logout(MethodCall methodCall, MethodChannel.Result result) { public void logout(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.logout(new BaseImpl(result)); Open_im_sdk.logout(new BaseListener(result));
} }
public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) { public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) {
@ -31,11 +31,11 @@ public class IMManager {
} }
public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) { public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getUsersInfo(CommonUtil.getUidList(methodCall), new BaseImpl(result)); Open_im_sdk.getUsersInfo(CommonUtil.getUidList(methodCall), new BaseListener(result));
} }
public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) { public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setSelfInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result)); Open_im_sdk.setSelfInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseListener(result));
} }
public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) { public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) {

@ -1,14 +1,12 @@
package io.openim.flutter_openim_sdk.manager; package io.openim.flutter_openim_sdk.manager;
import android.content.Context;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
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.openim.flutter_openim_sdk.listener.AdvancedMsgListenerImpl; import io.openim.flutter_openim_sdk.listener.AdvancedMsgListener;
import io.openim.flutter_openim_sdk.listener.BaseImpl; import io.openim.flutter_openim_sdk.listener.BaseListener;
import io.openim.flutter_openim_sdk.listener.MsgSendProgressListener; 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;
@ -22,7 +20,7 @@ public class MessageManager {
public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
String key = methodCall.argument(KEY_ID); String key = methodCall.argument(KEY_ID);
if (!listeners.containsKey(key)) { if (!listeners.containsKey(key)) {
AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(key); AdvancedMsgListener listener = new AdvancedMsgListener(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);
} }
@ -36,19 +34,23 @@ public class MessageManager {
public void sendMessage(MethodCall methodCall, MethodChannel.Result result) { public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
MsgSendProgressListener listener = new MsgSendProgressListener(result, methodCall); MsgSendProgressListener listener = new MsgSendProgressListener(result, methodCall);
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));
} }
public void getHistoryMessageList(MethodCall methodCall, MethodChannel.Result result) { public void getHistoryMessageList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getHistoryMessageList(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); Open_im_sdk.getHistoryMessageList(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall));
} }
public void revokeMessage(MethodCall methodCall, MethodChannel.Result result) { public void revokeMessage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.revokeMessage(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); Open_im_sdk.revokeMessage(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall));
} }
public void deleteMessageFromLocalStorage(MethodCall methodCall, MethodChannel.Result result) { public void deleteMessageFromLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteMessageFromLocalStorage(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); Open_im_sdk.deleteMessageFromLocalStorage(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall));
} }
public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) { public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) {
@ -56,46 +58,81 @@ public class MessageManager {
} }
public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) { public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.insertSingleMessageToLocalStorage(new BaseImpl(result), CommonUtil.getSingleMessageContent(methodCall), CommonUtil.getSingleMessageUserid(methodCall), CommonUtil.getSingleMessageSender(methodCall)); Open_im_sdk.insertSingleMessageToLocalStorage(new BaseListener(result),
CommonUtil.getSingleMessageContent(methodCall),
CommonUtil.getSingleMessageUserid(methodCall),
CommonUtil.getSingleMessageSender(methodCall));
} }
public void findMessages(MethodCall methodCall, MethodChannel.Result result) { public void findMessages(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.findMessages(new BaseImpl(result), CommonUtil.getFindMessageIds(methodCall)); Open_im_sdk.findMessages(new BaseListener(result), CommonUtil.getFindMessageIds(methodCall));
} }
public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) { public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.markSingleMessageHasRead(new BaseImpl(result), CommonUtil.getSingleMessageUserid(methodCall)); Open_im_sdk.markSingleMessageHasRead(new BaseListener(result), CommonUtil.getSingleMessageUserid(methodCall));
}
public void markGroupMessageHasRead(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.markGroupMessageHasRead(new BaseListener(result), CommonUtil.getGroupMessageGroupid(methodCall));
}
public void markC2CMessageAsRead(MethodCall methodCall, MethodChannel.Result result) {
// Open_im_sdk.markC2CMessageAsRead(new BaseImpl(result), CommonUtil.getSingleMessageUserid(methodCall));
} }
public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) { public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createTextMessage(CommonUtil.getMessageText(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createTextMessage(
CommonUtil.getMessageText(methodCall)));
} }
public void createTextAtMessage(MethodCall methodCall, MethodChannel.Result result) { public void createTextAtMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createTextAtMessage(CommonUtil.getMessageText(methodCall), CommonUtil.getAtUserList(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createTextAtMessage(
CommonUtil.getMessageText(methodCall),
CommonUtil.getAtUserList(methodCall)));
} }
public void createImageMessage(MethodCall methodCall, MethodChannel.Result result) { public void createImageMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createImageMessage(CommonUtil.getImagePath(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createImageMessage(
CommonUtil.getImagePath(methodCall)));
} }
public void createSoundMessage(MethodCall methodCall, MethodChannel.Result result) { public void createSoundMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createSoundMessage(CommonUtil.getSoundPath(methodCall), CommonUtil.getSoundDuration(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createSoundMessage(
CommonUtil.getSoundPath(methodCall),
CommonUtil.getSoundDuration(methodCall)));
} }
public void createVideoMessage(MethodCall methodCall, MethodChannel.Result result) { public void createVideoMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createVideoMessage(CommonUtil.getVideoPath(methodCall), CommonUtil.getVideoType(methodCall), CommonUtil.getVideoDuration(methodCall), CommonUtil.getVideoSnapshotPath(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createVideoMessage(
CommonUtil.getVideoPath(methodCall),
CommonUtil.getVideoType(methodCall),
CommonUtil.getVideoDuration(methodCall),
CommonUtil.getVideoSnapshotPath(methodCall)));
} }
public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) { public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createFileMessage(CommonUtil.getFilePath(methodCall), CommonUtil.getFileName(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createFileMessage(
CommonUtil.getFilePath(methodCall),
CommonUtil.getFileName(methodCall)));
} }
public void createMergerMessage(MethodCall methodCall, MethodChannel.Result result) { public void createMergerMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createMergerMessage(CommonUtil.getMergerMessageList(methodCall), CommonUtil.getMergerMessageTitle(methodCall), CommonUtil.getSummaryList(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createMergerMessage(
CommonUtil.getMergerMessageList(methodCall),
CommonUtil.getMergerMessageTitle(methodCall),
CommonUtil.getSummaryList(methodCall)));
} }
public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) { public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createForwardMessage(CommonUtil.getForwardMessage(methodCall))); CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createForwardMessage(
CommonUtil.getForwardMessage(methodCall)));
} }
} }

@ -85,15 +85,15 @@ public class CommonUtil {
/////////////////////////////////////// ///////////////////////////////////////
////////////////////////////////////// //////////////////////////////////////
public static String getUid(MethodCall methodCall) { public static String getUid(MethodCall methodCall) {
return getParamValue(methodCall, KEY_LOGIN_UID); return getParamValue(methodCall, KEY_UID);
} }
public static String getJsonUid(MethodCall methodCall) { public static String getJsonUid(MethodCall methodCall) {
return JsonUtil.toString(getParamValue(methodCall, KEY_LOGIN_UID)); return JsonUtil.toString(getParamValue(methodCall, KEY_UID));
} }
public static String getToken(MethodCall methodCall) { public static String getToken(MethodCall methodCall) {
return getParamValue(methodCall, KEY_LOGIN_TOKEN); return getParamValue(methodCall, KEY_TOKEN);
} }
public static String getMessageText(MethodCall methodCall) { public static String getMessageText(MethodCall methodCall) {
@ -191,6 +191,10 @@ public class CommonUtil {
return getParamValue(methodCall, KEY_SINGLE_MESSAGE_USERID); return getParamValue(methodCall, KEY_SINGLE_MESSAGE_USERID);
} }
public static String getGroupMessageGroupid(MethodCall methodCall) {
return getParamValue(methodCall, KEY_GROUP_MESSAGE_GROUPID);
}
public static String getSingleMessageSender(MethodCall methodCall) { public static String getSingleMessageSender(MethodCall methodCall) {
return getParamValue(methodCall, KEY_SINGLE_MESSAGE_SENDER); return getParamValue(methodCall, KEY_SINGLE_MESSAGE_SENDER);
} }
@ -227,10 +231,41 @@ public class CommonUtil {
return getSDKJsonParam(methodCall, KEY_USER_IDS); return getSDKJsonParam(methodCall, KEY_USER_IDS);
} }
public static String getGid(MethodCall methodCall) {
return getParamValue(methodCall, KEY_GROUP_ID);
}
public static String getGidList(MethodCall methodCall) {
return getSDKJsonParam(methodCall, KEY_GROUP_IDS);
}
public static String getGroupOpReason(MethodCall methodCall) {
return getParamValue(methodCall, KEY_GROUP_OP_REASON);
}
public static int getGroupListFilter(MethodCall methodCall) {
return getParamValue(methodCall, KEY_GROUP_LIST_FILTER);
}
public static int getGroupListNext(MethodCall methodCall) {
return getParamValue(methodCall, KEY_GROUP_LIST_NEXT);
}
public static String getGroupInfo(MethodCall methodCall) {
return getSDKJsonParam(methodCall, KEY_GROUP_INFO);
}
public static String getGroupMemberRoleList(MethodCall methodCall) {
return getSDKJsonParam(methodCall, KEY_GROUP_MEMBER_ROLE_LIST);
}
public static String getGroupApplicationInfo(MethodCall methodCall) {
return getSDKJsonParam(methodCall, KEY_GROUP_APPLICATION_INFO);
}
//login //login
final static String KEY_LOGIN_UID = "uid"; final static String KEY_UID = "uid";
final static String KEY_LOGIN_TOKEN = "token"; final static String KEY_TOKEN = "token";
//create message body //create message body
final static String KEY_TEXT = "text"; final static String KEY_TEXT = "text";
final static String KEY_AT_USER_LIST = "atUserList"; final static String KEY_AT_USER_LIST = "atUserList";
@ -257,6 +292,8 @@ public class CommonUtil {
final static String KEY_SINGLE_MESSAGE_CONTENT = "message"; final static String KEY_SINGLE_MESSAGE_CONTENT = "message";
final static String KEY_SINGLE_MESSAGE_USERID = "userID"; final static String KEY_SINGLE_MESSAGE_USERID = "userID";
final static String KEY_SINGLE_MESSAGE_SENDER = "sender"; final static String KEY_SINGLE_MESSAGE_SENDER = "sender";
//group chat
final static String KEY_GROUP_MESSAGE_GROUPID = "groupID";
// find message // find message
final static String KEY_FIND_MESSAGE_IDS = "messageIDList"; final static String KEY_FIND_MESSAGE_IDS = "messageIDList";
// conversation // conversation
@ -268,4 +305,15 @@ public class CommonUtil {
final static String KEY_CONVERSATION_SESSION_TYPE = "sessionType"; final static String KEY_CONVERSATION_SESSION_TYPE = "sessionType";
// user info // user info
final static String KEY_USER_IDS = "uidList"; final static String KEY_USER_IDS = "uidList";
// group
final static String KEY_GROUP_ID = "gid";
final static String KEY_GROUP_IDS = "gidList";
final static String KEY_GROUP_OP_REASON = "reason";
// final static String KEY_GROUP_USER_ID = "uid";
// final static String KEY_GROUP_USER_IDS = "uidList";
final static String KEY_GROUP_LIST_FILTER = "filter";
final static String KEY_GROUP_LIST_NEXT = "next";
final static String KEY_GROUP_INFO = "gInfo";
final static String KEY_GROUP_MEMBER_ROLE_LIST = "memberList";
final static String KEY_GROUP_APPLICATION_INFO = "application";
} }

@ -1,8 +1,13 @@
library flutter_openim_sdk;
export 'src/enum/conversation_type.dart';
export 'src/enum/group_role.dart';
export 'src/enum/listener_type.dart'; export 'src/enum/listener_type.dart';
export 'src/enum/message_type.dart'; export 'src/enum/message_type.dart';
export 'src/listener/advanced_msg_listener.dart'; export 'src/listener/advanced_msg_listener.dart';
export 'src/listener/conversation_listener.dart'; export 'src/listener/conversation_listener.dart';
export 'src/listener/friendship_listener.dart'; export 'src/listener/friendship_listener.dart';
export 'src/listener/group_listener.dart';
export 'src/listener/init_sdk_listener.dart'; export 'src/listener/init_sdk_listener.dart';
export 'src/listener/msg_send_progress_listener.dart'; export 'src/listener/msg_send_progress_listener.dart';
export 'src/manager/im_conversation_manager.dart'; export 'src/manager/im_conversation_manager.dart';
@ -13,6 +18,7 @@ export 'src/manager/im_message_manager.dart';
export 'src/manager/im_offline_push_manager.dart'; export 'src/manager/im_offline_push_manager.dart';
export 'src/manager/im_signaling_manager.dart'; export 'src/manager/im_signaling_manager.dart';
export 'src/models/conversation_info.dart'; export 'src/models/conversation_info.dart';
export 'src/models/group_info.dart';
export 'src/models/message.dart'; export 'src/models/message.dart';
export 'src/models/user_info.dart'; export 'src/models/user_info.dart';
export 'src/openim.dart'; export 'src/openim.dart';

@ -0,0 +1,4 @@
class ConversationType{
static const int single_chat = 1;
static const int group_chat = 2;
}

@ -0,0 +1,5 @@
class GroupRole {
static const member = 0;
static const owner = 1;
static const admin = 2;
}

@ -15,4 +15,6 @@ class MessageType {
static const file = 105; static const file = 105;
static const accept_friend = 201; static const accept_friend = 201;
static const create_group = 502;
} }

@ -0,0 +1,36 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class GroupListener {
void onMemberEnter(String groupId, List<GroupMembersInfo> list) {}
void onMemberLeave(String groupId, GroupMembersInfo info) {}
void onMemberInvited(
String groupId,
GroupMembersInfo opUser,
List<GroupMembersInfo> list,
) {}
void onMemberKicked(
String groupId,
GroupMembersInfo opUser,
List<GroupMembersInfo> list,
) {}
void onGroupCreated(String groupId) {}
void onGroupInfoChanged(String groupId, GroupInfo info) {}
void onReceiveJoinApplication(
String groupId,
GroupMembersInfo info,
String opReason,
) {}
void onApplicationProcessed(
String groupId,
GroupMembersInfo opUser,
int agreeOrReject,
String opReason,
) {}
}

@ -20,8 +20,8 @@ class ConversationManager {
.then((value) => _toList(value)); .then((value) => _toList(value));
} }
/// sourceID userID,groupID /// sourceID: userID(single chat) ,groupID(group chat)
/// sessionType 1,2 /// sessionType: 1(single chat) ,2(group chat)
Future<ConversationInfo> getSingleConversation( Future<ConversationInfo> getSingleConversation(
{required String sourceID, required String sessionType}) { {required String sourceID, required String sessionType}) {
return _channel return _channel

@ -1,13 +1,20 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/src/listener/group_listener.dart';
import 'package:flutter_openim_sdk/src/models/group_info.dart'; import 'package:flutter_openim_sdk/src/models/group_info.dart';
class GroupManager { class GroupManager {
MethodChannel _channel; MethodChannel _channel;
late GroupListener groupListener;
GroupManager(this._channel); GroupManager(this._channel);
void setGroupListener(GroupListener listener) {
this.groupListener = listener;
_channel.invokeMethod('setGroupListener', _buildParam({}));
}
Future<List<GroupInviteResult>> inviteUserToGroup({ Future<List<GroupInviteResult>> inviteUserToGroup({
required String groupId, required String groupId,
required List<String> uidList, required List<String> uidList,
@ -21,7 +28,7 @@ class GroupManager {
'reason': reason, 'reason': reason,
'uidList': uidList, 'uidList': uidList,
})) }))
.then((value) => _formatJson(value) .then((value) => (_formatJson(value) as List)
.map((e) => GroupInviteResult.fromJson(e)) .map((e) => GroupInviteResult.fromJson(e))
.toList()); .toList());
} }
@ -55,7 +62,7 @@ class GroupManager {
'gid': groupId, 'gid': groupId,
'uidList': uidList, 'uidList': uidList,
})) }))
.then((value) => _formatJson(value) .then((value) => (_formatJson(value) as List)
.map((e) => GroupMembersInfo.fromJson(e)) .map((e) => GroupMembersInfo.fromJson(e))
.toList()); .toList());
} }
@ -80,22 +87,27 @@ class GroupManager {
Future<List<GroupInfo>> getJoinedGroupList() { Future<List<GroupInfo>> getJoinedGroupList() {
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then( return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then(
(value) => (value) => (_formatJson(value) as List)
_formatJson(value).map((e) => GroupInfo.fromJson(e)).toList()); .map((e) => GroupInfo.fromJson(e))
.toList());
} }
Future<String> createGroup({ Future<bool> isJoinedGroup({required String gid}) {
required GroupInfo groupInfo, return getJoinedGroupList()
.then((list) => list.where((e) => e.groupID == gid).length > 0);
}
Future<dynamic> createGroup({
GroupInfo? groupInfo,
required List<GroupMemberRole> list, required List<GroupMemberRole> list,
}) { }) {
return _channel return _channel.invokeMethod(
.invokeMethod( 'createGroup',
'createGroup', _buildParam({
_buildParam({ 'gInfo': groupInfo?.toJson(),
'gInfo': groupInfo.toJson(), 'memberList': list.map((e) => e.toJson()).toList()
'memberList': list.map((e) => e.toJson()).toList() }));
})) /*.then((value) => _formatJson(value)['groupID'])*/
.then((value) => _formatJson(value)['groupID']);
} }
Future<dynamic> setGroupInfo({ Future<dynamic> setGroupInfo({
@ -113,13 +125,15 @@ class GroupManager {
}) { }) {
return _channel return _channel
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList})) .invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList}))
.then((value) => .then((value) {
_formatJson(value).map((e) => GroupInfo.fromJson(e)).toList()); List list = _formatJson(value) ?? [];
return list.map((e) => GroupInfo.fromJson(e)).toList();
});
} }
Future<dynamic> joinGroup({ Future<dynamic> joinGroup({
required String gid, required String gid,
required String reason, String? reason,
}) { }) {
return _channel.invokeMethod( return _channel.invokeMethod(
'joinGroup', 'joinGroup',

@ -12,6 +12,7 @@ class IMManager {
late OfflinePushManager offlinePushManager; late OfflinePushManager offlinePushManager;
late SignalingManager signalingManager; late SignalingManager signalingManager;
late InitSDKListener _initSDKListener; late InitSDKListener _initSDKListener;
late String logUid;
IMManager(this._channel) { IMManager(this._channel) {
conversationManager = ConversationManager(_channel); conversationManager = ConversationManager(_channel);
@ -55,71 +56,83 @@ class IMManager {
} else if (call.method == ListenerType.groupListener) { } else if (call.method == ListenerType.groupListener) {
var args = call.arguments; var args = call.arguments;
String type = args['type']; String type = args['type'];
Map<String, dynamic> params = args['data'] == null Map<dynamic, dynamic> map = args['data'];
? new Map<String, dynamic>()
: new Map<String, dynamic>.from(args['data']);
String groupID = params['groupID'] == null ? '' : params['groupID'];
String opReason =
params['opReason'] == null ? '' : params['opReason'];
bool isAgreeJoin =
params['isAgreeJoin'] == null ? false : params['isAgreeJoin'];
String customData =
params['customData'] == null ? '' : params['customData'];
Map<String, String> groupAttributeMap =
params['groupAttributeMap'] == null
? new Map<String, String>()
: new Map<String, String>.from(params['groupAttributeMap']);
List<Map<String, dynamic>> memberListMap =
params['memberList'] == null
? List.empty(growable: true)
: List.from(params['memberList']);
List<Map<String, dynamic>> groupMemberChangeInfoListMap =
params['groupMemberChangeInfoList'] == null
? List.empty(growable: true)
: List.from(params['groupMemberChangeInfoList']);
List<Map<String, dynamic>> groupChangeInfoListMap =
params['groupChangeInfoList'] == null
? List.empty(growable: true)
: List.from(params['groupChangeInfoList']);
switch (type) { switch (type) {
case 'onMemberEnter': case 'onMemberEnter':
groupManager.groupListener.onMemberEnter(
map['groupId'],
(_formatJson(map['memberList']) as List)
.map((e) => GroupMembersInfo.fromJson(e))
.toList(),
);
break; break;
case 'onMemberLeave': case 'onMemberLeave':
groupManager.groupListener.onMemberLeave(
map['groupId'],
GroupMembersInfo.fromJson(_formatJson(map['member'])),
);
break; break;
case 'onMemberInvited': case 'onMemberInvited':
groupManager.groupListener.onMemberInvited(
map['groupId'],
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
(_formatJson(map['memberList']) as List)
.map((e) => GroupMembersInfo.fromJson(e))
.toList(),
);
break; break;
case 'onMemberKicked': case 'onMemberKicked':
break; groupManager.groupListener.onMemberKicked(
case 'onMemberInfoChanged': map['groupId'],
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
(_formatJson(map['memberList']) as List)
.map((e) => GroupMembersInfo.fromJson(e))
.toList(),
);
break; break;
case 'onGroupCreated': case 'onGroupCreated':
break; groupManager.groupListener.onGroupCreated(
case 'onGroupDismissed': map['groupId'],
break; );
case 'onGroupRecycled':
break; break;
case 'onGroupInfoChanged': case 'onGroupInfoChanged':
groupManager.groupListener.onGroupInfoChanged(
map['groupId'],
GroupInfo.fromJson(_formatJson(map['groupInfo'])),
);
break; break;
case 'onReceiveJoinApplication': case 'onReceiveJoinApplication':
groupManager.groupListener.onReceiveJoinApplication(
map['groupId'],
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
map['opReason'],
);
break; break;
case 'onApplicationProcessed': case 'onApplicationProcessed':
groupManager.groupListener.onApplicationProcessed(
map['groupId'],
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
map['agreeOrReject'],
map['opReason'],
);
break; break;
case 'onGrantAdministrator': // case 'onMemberInfoChanged':
break; // break;
case 'onRevokeAdministrator': // case 'onGroupDismissed':
break; // break;
case 'onQuitFromGroup': // case 'onGroupRecycled':
break; // break;
case 'onReceiveRESTCustomData': //
break; // case 'onGrantAdministrator':
case 'onGroupAttributeChanged': // break;
break; // case 'onRevokeAdministrator':
// break;
// case 'onQuitFromGroup':
// break;
// case 'onReceiveRESTCustomData':
// break;
// case 'onGroupAttributeChanged':
// break;
} }
} else if (call.method == ListenerType.advancedMsgListener) { } else if (call.method == ListenerType.advancedMsgListener) {
var type = call.arguments['type']; var type = call.arguments['type'];
@ -266,6 +279,7 @@ class IMManager {
} }
Future<dynamic> login({required String uid, required String token}) { Future<dynamic> login({required String uid, required String token}) {
this.logUid = uid;
return _channel.invokeMethod( return _channel.invokeMethod(
'login', 'login',
_buildParam({'uid': uid, 'token': token}), _buildParam({'uid': uid, 'token': token}),

@ -103,6 +103,11 @@ class MessageManager {
'markSingleMessageHasRead', _buildParam({'userID': userID})); 'markSingleMessageHasRead', _buildParam({'userID': userID}));
} }
Future<dynamic> markGroupMessageHasRead({required String groupID}) {
return _channel.invokeMethod(
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
}
Future<Message> createTextMessage({required String text}) { Future<Message> createTextMessage({required String text}) {
return _channel return _channel
.invokeMethod('createTextMessage', _buildParam({'text': text})) .invokeMethod('createTextMessage', _buildParam({'text': text}))

@ -74,4 +74,8 @@ class ConversationInfo {
data['isPinned'] = this.isPinned; data['isPinned'] = this.isPinned;
return data; return data;
} }
bool get isSingleChat => conversationType == ConversationType.single_chat;
bool get isGroupChat => conversationType == ConversationType.group_chat;
} }

@ -1,5 +1,5 @@
class GroupInfo { class GroupInfo {
String? groupID; String groupID;
String? groupName; String? groupName;
String? notification; String? notification;
String? introduction; String? introduction;
@ -9,7 +9,7 @@ class GroupInfo {
int? memberCount; int? memberCount;
GroupInfo( GroupInfo(
{this.groupID, {required this.groupID,
this.groupName, this.groupName,
this.notification, this.notification,
this.introduction, this.introduction,
@ -18,8 +18,8 @@ class GroupInfo {
this.createTime, this.createTime,
this.memberCount}); this.memberCount});
GroupInfo.fromJson(Map<String, dynamic> json) { GroupInfo.fromJson(Map<String, dynamic> json): groupID = json['groupID'] {
groupID = json['groupID']; /*groupID = json['groupID'];*/
groupName = json['groupName']; groupName = json['groupName'];
notification = json['notification']; notification = json['notification'];
introduction = json['introduction']; introduction = json['introduction'];
@ -126,7 +126,7 @@ class GroupInviteResult {
class GroupMemberRole { class GroupMemberRole {
String? uid; String? uid;
int? setRole; //02 int? setRole;
GroupMemberRole({this.uid, this.setRole}); GroupMemberRole({this.uid, this.setRole});

@ -2,16 +2,16 @@ class UserInfo {
String uid; String uid;
String? name; String? name;
String? icon; String? icon;
int? gender; // 0 1 2 int? gender;
String? mobile; String? mobile;
String? birth; String? birth;
String? email; String? email;
String? ex; String? ex;
String? comment; String? comment;
int? isInBlackList; // 0 1 int? isInBlackList;
String? reqMessage; String? reqMessage;
String? applyTime; String? applyTime;
int? flag; // //01-1 int? flag;
UserInfo( UserInfo(
{required this.uid, {required this.uid,
@ -61,5 +61,25 @@ class UserInfo {
return data; return data;
} }
String get nickname => comment ?? name ?? uid; String getShowName() {
if (null != comment && comment!.trim().isNotEmpty) {
return comment!;
} else if (null != name && name!.trim().isNotEmpty) {
return name!;
}
return uid;
}
bool get isMan => gender == 1;
bool get isWoman => gender == 2;
/// blacklist
bool get isBlocked => isInBlackList == 1;
/// friend application
bool get isAgreed => flag == 1;
/// friend application
bool get isRejected => flag == -1;
} }

@ -6,4 +6,6 @@ class OpenIM {
const MethodChannel('flutter_openim_sdk'); const MethodChannel('flutter_openim_sdk');
static IMManager iMManager = IMManager(_channel); static IMManager iMManager = IMManager(_channel);
OpenIM._();
} }

Loading…
Cancel
Save