add group fuc
This commit is contained in:
parent
073b91ba99
commit
3acbacda6d
@ -16,6 +16,7 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
import io.openim.flutter_openim_sdk.manager.ConversationManager;
|
||||
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.MessageManager;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
@ -35,6 +36,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler
|
||||
private static FriendshipManager friendshipManager;
|
||||
private static MessageManager messageManager;
|
||||
private static ConversationManager conversationManager;
|
||||
private static GroupManager groupManager;
|
||||
|
||||
public FlutterOpenimSdkPlugin() {
|
||||
}
|
||||
@ -44,6 +46,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler
|
||||
FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager();
|
||||
FlutterOpenimSdkPlugin.messageManager = new MessageManager();
|
||||
FlutterOpenimSdkPlugin.conversationManager = new ConversationManager();
|
||||
FlutterOpenimSdkPlugin.groupManager = new GroupManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,10 +6,10 @@ import java.util.Map;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
import open_im_sdk.OnAdvancedMsgListener;
|
||||
|
||||
public class AdvancedMsgListenerImpl implements OnAdvancedMsgListener {
|
||||
public class AdvancedMsgListener implements OnAdvancedMsgListener {
|
||||
final Map<String, String> values = new HashMap<>();
|
||||
|
||||
public AdvancedMsgListenerImpl(String listenerId) {
|
||||
public AdvancedMsgListener(String 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 open_im_sdk.Base;
|
||||
|
||||
public class BaseImpl implements Base {
|
||||
public class BaseListener implements Base {
|
||||
|
||||
MethodChannel.Result result;
|
||||
|
||||
public BaseImpl(MethodChannel.Result result) {
|
||||
public BaseListener(MethodChannel.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 open_im_sdk.OnConversationListener;
|
||||
|
||||
public class ConversationListenerImpl implements OnConversationListener {
|
||||
public class ConversationListener implements OnConversationListener {
|
||||
|
||||
|
||||
@Override
|
@ -3,7 +3,7 @@ package io.openim.flutter_openim_sdk.listener;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
import open_im_sdk.OnFriendshipListener;
|
||||
|
||||
public class FriendshipListenerImpl implements OnFriendshipListener {
|
||||
public class FriendshipListener implements OnFriendshipListener {
|
||||
|
||||
@Override
|
||||
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 open_im_sdk.IMSDKListener;
|
||||
|
||||
public class SDKListenerImpl implements IMSDKListener {
|
||||
public class SDKListener implements IMSDKListener {
|
||||
|
||||
@Override
|
||||
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.MethodChannel;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.ConversationListenerImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseListener;
|
||||
import io.openim.flutter_openim_sdk.listener.ConversationListener;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
import open_im_sdk.Open_im_sdk;
|
||||
|
||||
public class ConversationManager {
|
||||
|
||||
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) {
|
||||
Open_im_sdk.getAllConversationList(new BaseImpl(result));
|
||||
Open_im_sdk.getAllConversationList(new BaseListener(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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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.MethodChannel;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.FriendshipListenerImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseListener;
|
||||
import io.openim.flutter_openim_sdk.listener.FriendshipListener;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
import open_im_sdk.Open_im_sdk;
|
||||
|
||||
@ -11,55 +11,55 @@ public class FriendshipManager {
|
||||
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
Open_im_sdk.getFriendApplicationList(new BaseImpl(result));
|
||||
Open_im_sdk.getFriendApplicationList(new BaseListener(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) {
|
||||
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) {
|
||||
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) {
|
||||
Open_im_sdk.getBlackList(new BaseImpl(result));
|
||||
Open_im_sdk.getBlackList(new BaseListener(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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
|
@ -1,6 +1,113 @@
|
||||
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 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.MethodChannel;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.SDKListenerImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseListener;
|
||||
import io.openim.flutter_openim_sdk.listener.SDKListener;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
import open_im_sdk.Open_im_sdk;
|
||||
|
||||
public class IMManager {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
Open_im_sdk.logout(new BaseImpl(result));
|
||||
Open_im_sdk.logout(new BaseListener(result));
|
||||
}
|
||||
|
||||
public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) {
|
||||
@ -31,11 +31,11 @@ public class IMManager {
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
@ -1,14 +1,12 @@
|
||||
package io.openim.flutter_openim_sdk.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.openim.flutter_openim_sdk.listener.AdvancedMsgListenerImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseImpl;
|
||||
import io.openim.flutter_openim_sdk.listener.AdvancedMsgListener;
|
||||
import io.openim.flutter_openim_sdk.listener.BaseListener;
|
||||
import io.openim.flutter_openim_sdk.listener.MsgSendProgressListener;
|
||||
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||
import open_im_sdk.OnAdvancedMsgListener;
|
||||
@ -22,7 +20,7 @@ public class MessageManager {
|
||||
public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
|
||||
String key = methodCall.argument(KEY_ID);
|
||||
if (!listeners.containsKey(key)) {
|
||||
AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(key);
|
||||
AdvancedMsgListener listener = new AdvancedMsgListener(key);
|
||||
listeners.put(methodCall.argument(KEY_ID), listener);
|
||||
Open_im_sdk.addAdvancedMsgListener(listener);
|
||||
}
|
||||
@ -36,19 +34,23 @@ public class MessageManager {
|
||||
|
||||
public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
@ -56,46 +58,81 @@ public class MessageManager {
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
return getParamValue(methodCall, KEY_LOGIN_UID);
|
||||
return getParamValue(methodCall, KEY_UID);
|
||||
}
|
||||
|
||||
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) {
|
||||
return getParamValue(methodCall, KEY_LOGIN_TOKEN);
|
||||
return getParamValue(methodCall, KEY_TOKEN);
|
||||
}
|
||||
|
||||
public static String getMessageText(MethodCall methodCall) {
|
||||
@ -191,6 +191,10 @@ public class CommonUtil {
|
||||
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) {
|
||||
return getParamValue(methodCall, KEY_SINGLE_MESSAGE_SENDER);
|
||||
}
|
||||
@ -227,10 +231,41 @@ public class CommonUtil {
|
||||
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
|
||||
final static String KEY_LOGIN_UID = "uid";
|
||||
final static String KEY_LOGIN_TOKEN = "token";
|
||||
final static String KEY_UID = "uid";
|
||||
final static String KEY_TOKEN = "token";
|
||||
//create message body
|
||||
final static String KEY_TEXT = "text";
|
||||
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_USERID = "userID";
|
||||
final static String KEY_SINGLE_MESSAGE_SENDER = "sender";
|
||||
//group chat
|
||||
final static String KEY_GROUP_MESSAGE_GROUPID = "groupID";
|
||||
// find message
|
||||
final static String KEY_FIND_MESSAGE_IDS = "messageIDList";
|
||||
// conversation
|
||||
@ -268,4 +305,15 @@ public class CommonUtil {
|
||||
final static String KEY_CONVERSATION_SESSION_TYPE = "sessionType";
|
||||
// user info
|
||||
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/message_type.dart';
|
||||
export 'src/listener/advanced_msg_listener.dart';
|
||||
export 'src/listener/conversation_listener.dart';
|
||||
export 'src/listener/friendship_listener.dart';
|
||||
export 'src/listener/group_listener.dart';
|
||||
export 'src/listener/init_sdk_listener.dart';
|
||||
export 'src/listener/msg_send_progress_listener.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_signaling_manager.dart';
|
||||
export 'src/models/conversation_info.dart';
|
||||
export 'src/models/group_info.dart';
|
||||
export 'src/models/message.dart';
|
||||
export 'src/models/user_info.dart';
|
||||
export 'src/openim.dart';
|
||||
|
4
lib/src/enum/conversation_type.dart
Normal file
4
lib/src/enum/conversation_type.dart
Normal file
@ -0,0 +1,4 @@
|
||||
class ConversationType{
|
||||
static const int single_chat = 1;
|
||||
static const int group_chat = 2;
|
||||
}
|
5
lib/src/enum/group_role.dart
Normal file
5
lib/src/enum/group_role.dart
Normal file
@ -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 accept_friend = 201;
|
||||
|
||||
static const create_group = 502;
|
||||
}
|
||||
|
36
lib/src/listener/group_listener.dart
Normal file
36
lib/src/listener/group_listener.dart
Normal file
@ -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));
|
||||
}
|
||||
|
||||
/// sourceID 若为单聊则为userID,若为群聊则为groupID
|
||||
/// sessionType 若为单聊则为1,若为群聊则为2
|
||||
/// sourceID: userID(single chat) ,groupID(group chat)
|
||||
/// sessionType: 1(single chat) ,2(group chat)
|
||||
Future<ConversationInfo> getSingleConversation(
|
||||
{required String sourceID, required String sessionType}) {
|
||||
return _channel
|
||||
|
@ -1,13 +1,20 @@
|
||||
import 'dart:convert';
|
||||
|
||||
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';
|
||||
|
||||
class GroupManager {
|
||||
MethodChannel _channel;
|
||||
late GroupListener groupListener;
|
||||
|
||||
GroupManager(this._channel);
|
||||
|
||||
void setGroupListener(GroupListener listener) {
|
||||
this.groupListener = listener;
|
||||
_channel.invokeMethod('setGroupListener', _buildParam({}));
|
||||
}
|
||||
|
||||
Future<List<GroupInviteResult>> inviteUserToGroup({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
@ -21,7 +28,7 @@ class GroupManager {
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => _formatJson(value)
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
@ -55,7 +62,7 @@ class GroupManager {
|
||||
'gid': groupId,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => _formatJson(value)
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
@ -80,22 +87,27 @@ class GroupManager {
|
||||
|
||||
Future<List<GroupInfo>> getJoinedGroupList() {
|
||||
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then(
|
||||
(value) =>
|
||||
_formatJson(value).map((e) => GroupInfo.fromJson(e)).toList());
|
||||
(value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInfo.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<String> createGroup({
|
||||
required GroupInfo groupInfo,
|
||||
Future<bool> isJoinedGroup({required String gid}) {
|
||||
return getJoinedGroupList()
|
||||
.then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
}
|
||||
|
||||
Future<dynamic> createGroup({
|
||||
GroupInfo? groupInfo,
|
||||
required List<GroupMemberRole> list,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': groupInfo.toJson(),
|
||||
'memberList': list.map((e) => e.toJson()).toList()
|
||||
}))
|
||||
.then((value) => _formatJson(value)['groupID']);
|
||||
return _channel.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': groupInfo?.toJson(),
|
||||
'memberList': list.map((e) => e.toJson()).toList()
|
||||
}));
|
||||
/*.then((value) => _formatJson(value)['groupID'])*/
|
||||
}
|
||||
|
||||
Future<dynamic> setGroupInfo({
|
||||
@ -113,13 +125,15 @@ class GroupManager {
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList}))
|
||||
.then((value) =>
|
||||
_formatJson(value).map((e) => GroupInfo.fromJson(e)).toList());
|
||||
.then((value) {
|
||||
List list = _formatJson(value) ?? [];
|
||||
return list.map((e) => GroupInfo.fromJson(e)).toList();
|
||||
});
|
||||
}
|
||||
|
||||
Future<dynamic> joinGroup({
|
||||
required String gid,
|
||||
required String reason,
|
||||
String? reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'joinGroup',
|
||||
|
@ -12,6 +12,7 @@ class IMManager {
|
||||
late OfflinePushManager offlinePushManager;
|
||||
late SignalingManager signalingManager;
|
||||
late InitSDKListener _initSDKListener;
|
||||
late String logUid;
|
||||
|
||||
IMManager(this._channel) {
|
||||
conversationManager = ConversationManager(_channel);
|
||||
@ -55,71 +56,83 @@ class IMManager {
|
||||
} else if (call.method == ListenerType.groupListener) {
|
||||
var args = call.arguments;
|
||||
String type = args['type'];
|
||||
Map<String, dynamic> params = args['data'] == null
|
||||
? 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']);
|
||||
|
||||
Map<dynamic, dynamic> map = args['data'];
|
||||
switch (type) {
|
||||
case 'onMemberEnter':
|
||||
groupManager.groupListener.onMemberEnter(
|
||||
map['groupId'],
|
||||
(_formatJson(map['memberList']) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
break;
|
||||
case 'onMemberLeave':
|
||||
groupManager.groupListener.onMemberLeave(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['member'])),
|
||||
);
|
||||
break;
|
||||
case 'onMemberInvited':
|
||||
groupManager.groupListener.onMemberInvited(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
(_formatJson(map['memberList']) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
break;
|
||||
case 'onMemberKicked':
|
||||
break;
|
||||
case 'onMemberInfoChanged':
|
||||
groupManager.groupListener.onMemberKicked(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
(_formatJson(map['memberList']) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
break;
|
||||
case 'onGroupCreated':
|
||||
break;
|
||||
case 'onGroupDismissed':
|
||||
break;
|
||||
case 'onGroupRecycled':
|
||||
groupManager.groupListener.onGroupCreated(
|
||||
map['groupId'],
|
||||
);
|
||||
break;
|
||||
case 'onGroupInfoChanged':
|
||||
groupManager.groupListener.onGroupInfoChanged(
|
||||
map['groupId'],
|
||||
GroupInfo.fromJson(_formatJson(map['groupInfo'])),
|
||||
);
|
||||
break;
|
||||
case 'onReceiveJoinApplication':
|
||||
groupManager.groupListener.onReceiveJoinApplication(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
map['opReason'],
|
||||
);
|
||||
break;
|
||||
case 'onApplicationProcessed':
|
||||
groupManager.groupListener.onApplicationProcessed(
|
||||
map['groupId'],
|
||||
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
|
||||
map['agreeOrReject'],
|
||||
map['opReason'],
|
||||
);
|
||||
break;
|
||||
case 'onGrantAdministrator':
|
||||
break;
|
||||
case 'onRevokeAdministrator':
|
||||
break;
|
||||
case 'onQuitFromGroup':
|
||||
break;
|
||||
case 'onReceiveRESTCustomData':
|
||||
break;
|
||||
case 'onGroupAttributeChanged':
|
||||
break;
|
||||
// case 'onMemberInfoChanged':
|
||||
// break;
|
||||
// case 'onGroupDismissed':
|
||||
// break;
|
||||
// case 'onGroupRecycled':
|
||||
// break;
|
||||
//
|
||||
// case 'onGrantAdministrator':
|
||||
// break;
|
||||
// case 'onRevokeAdministrator':
|
||||
// break;
|
||||
// case 'onQuitFromGroup':
|
||||
// break;
|
||||
// case 'onReceiveRESTCustomData':
|
||||
// break;
|
||||
// case 'onGroupAttributeChanged':
|
||||
// break;
|
||||
}
|
||||
} else if (call.method == ListenerType.advancedMsgListener) {
|
||||
var type = call.arguments['type'];
|
||||
@ -266,6 +279,7 @@ class IMManager {
|
||||
}
|
||||
|
||||
Future<dynamic> login({required String uid, required String token}) {
|
||||
this.logUid = uid;
|
||||
return _channel.invokeMethod(
|
||||
'login',
|
||||
_buildParam({'uid': uid, 'token': token}),
|
||||
|
@ -103,6 +103,11 @@ class MessageManager {
|
||||
'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
}
|
||||
|
||||
Future<dynamic> markGroupMessageHasRead({required String groupID}) {
|
||||
return _channel.invokeMethod(
|
||||
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
|
||||
}
|
||||
|
||||
Future<Message> createTextMessage({required String text}) {
|
||||
return _channel
|
||||
.invokeMethod('createTextMessage', _buildParam({'text': text}))
|
||||
|
@ -74,4 +74,8 @@ class ConversationInfo {
|
||||
data['isPinned'] = this.isPinned;
|
||||
return data;
|
||||
}
|
||||
|
||||
bool get isSingleChat => conversationType == ConversationType.single_chat;
|
||||
|
||||
bool get isGroupChat => conversationType == ConversationType.group_chat;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
class GroupInfo {
|
||||
String? groupID;
|
||||
String groupID;
|
||||
String? groupName;
|
||||
String? notification;
|
||||
String? introduction;
|
||||
@ -9,7 +9,7 @@ class GroupInfo {
|
||||
int? memberCount;
|
||||
|
||||
GroupInfo(
|
||||
{this.groupID,
|
||||
{required this.groupID,
|
||||
this.groupName,
|
||||
this.notification,
|
||||
this.introduction,
|
||||
@ -18,8 +18,8 @@ class GroupInfo {
|
||||
this.createTime,
|
||||
this.memberCount});
|
||||
|
||||
GroupInfo.fromJson(Map<String, dynamic> json) {
|
||||
groupID = json['groupID'];
|
||||
GroupInfo.fromJson(Map<String, dynamic> json): groupID = json['groupID'] {
|
||||
/*groupID = json['groupID'];*/
|
||||
groupName = json['groupName'];
|
||||
notification = json['notification'];
|
||||
introduction = json['introduction'];
|
||||
@ -126,7 +126,7 @@ class GroupInviteResult {
|
||||
|
||||
class GroupMemberRole {
|
||||
String? uid;
|
||||
int? setRole; //0普通成员,2管理员
|
||||
int? setRole;
|
||||
|
||||
GroupMemberRole({this.uid, this.setRole});
|
||||
|
||||
|
@ -2,16 +2,16 @@ class UserInfo {
|
||||
String uid;
|
||||
String? name;
|
||||
String? icon;
|
||||
int? gender; // 0 未知,1 男,2 女
|
||||
int? gender;
|
||||
String? mobile;
|
||||
String? birth;
|
||||
String? email;
|
||||
String? ex;
|
||||
String? comment;
|
||||
int? isInBlackList; // 0 不在黑名单,1 在黑名单
|
||||
int? isInBlackList;
|
||||
String? reqMessage;
|
||||
String? applyTime;
|
||||
int? flag; // //0请求添加好友,1同意添加好友,-1拒绝添加好友
|
||||
int? flag;
|
||||
|
||||
UserInfo(
|
||||
{required this.uid,
|
||||
@ -61,5 +61,25 @@ class UserInfo {
|
||||
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');
|
||||
|
||||
static IMManager iMManager = IMManager(_channel);
|
||||
|
||||
OpenIM._();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user