commit
6703701f63
@ -8,7 +8,7 @@ buildscript {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
|
||||
maven { url 'http://47.112.160.66:8081/repository/maven-releases'}
|
||||
maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
|
||||
// maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
@ -25,7 +25,7 @@ rootProject.allprojects {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
|
||||
maven { url 'http://47.112.160.66:8081/repository/maven-releases'}
|
||||
maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
|
||||
// maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
@ -45,6 +45,6 @@ android {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'io.openim:client-sdk:0.0.1@aar'
|
||||
// implementation 'io.openim:client-sdk:1.0.0@aar'//graoupId:artifactId:version@aar
|
||||
// implementation 'io.openim:client:0.0.7@aar'
|
||||
implementation 'io.openim:client-sdk:0.0.2@aar'//graoupId:artifactId:version@aar
|
||||
}
|
@ -54,7 +54,7 @@ public class MessageManager {
|
||||
}
|
||||
|
||||
public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) {
|
||||
// Open_im_sdk.deleteMessages(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
|
||||
// Open_im_sdk.deleteMessages(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall));
|
||||
}
|
||||
|
||||
public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
@ -65,7 +65,7 @@ public class MessageManager {
|
||||
}
|
||||
|
||||
public void findMessages(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.findMessages(new BaseListener(result), CommonUtil.getFindMessageIds(methodCall));
|
||||
Open_im_sdk.findMessages(new BaseListener(result), CommonUtil.getMessageIdList(methodCall));
|
||||
}
|
||||
|
||||
public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) {
|
||||
@ -77,7 +77,14 @@ public class MessageManager {
|
||||
}
|
||||
|
||||
public void markC2CMessageAsRead(MethodCall methodCall, MethodChannel.Result result) {
|
||||
// Open_im_sdk.markC2CMessageAsRead(new BaseImpl(result), CommonUtil.getSingleMessageUserid(methodCall));
|
||||
Open_im_sdk.markC2CMessageAsRead(new BaseListener(result),
|
||||
CommonUtil.getSingleMessageUserid(methodCall),
|
||||
CommonUtil.getMessageIdList(methodCall));
|
||||
}
|
||||
|
||||
public void typingStatusUpdate(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.typingStatusUpdate(CommonUtil.getSingleMessageUserid(methodCall),
|
||||
CommonUtil.getSingleMessageTyping(methodCall));
|
||||
}
|
||||
|
||||
public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
|
@ -199,7 +199,11 @@ public class CommonUtil {
|
||||
return getParamValue(methodCall, KEY_SINGLE_MESSAGE_SENDER);
|
||||
}
|
||||
|
||||
public static String getFindMessageIds(MethodCall methodCall) {
|
||||
public static String getSingleMessageTyping(MethodCall methodCall) {
|
||||
return getParamValue(methodCall, KEY_SINGLE_MESSAGE_TYPING);
|
||||
}
|
||||
|
||||
public static String getMessageIdList(MethodCall methodCall) {
|
||||
return getSDKJsonParam(methodCall, KEY_FIND_MESSAGE_IDS);
|
||||
}
|
||||
|
||||
@ -288,6 +292,7 @@ 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";
|
||||
final static String KEY_SINGLE_MESSAGE_TYPING = "typing";
|
||||
//group chat
|
||||
final static String KEY_GROUP_MESSAGE_GROUPID = "groupID";
|
||||
// find message
|
||||
|
@ -19,6 +19,7 @@ export 'src/manager/im_manager.dart';
|
||||
export 'src/manager/im_message_manager.dart';
|
||||
export 'src/manager/im_offline_push_manager.dart';
|
||||
export 'src/manager/im_signaling_manager.dart';
|
||||
export 'src/manager/v2/im_message_manager_v2.dart';
|
||||
export 'src/models/conversation_info.dart';
|
||||
export 'src/models/group_info.dart';
|
||||
export 'src/models/message.dart';
|
||||
|
@ -7,6 +7,9 @@ class MessageType {
|
||||
static const file = 105;
|
||||
static const at_text = 106;
|
||||
static const merger = 107;
|
||||
static const revoke = 111;
|
||||
static const has_read_receipt = 112;
|
||||
static const typing = 113;
|
||||
|
||||
///
|
||||
static const accept_friend = 201;
|
||||
|
@ -9,7 +9,7 @@ class AdvancedMsgListener {
|
||||
|
||||
void onRecvNewMessage(Message msg) {}
|
||||
|
||||
void onRecvC2CReadReceipt(Message msg) {}
|
||||
void onRecvC2CReadReceipt(HaveReadInfo info) {}
|
||||
|
||||
void onRecvMessageRevoked(Message msg) {}
|
||||
void onRecvMessageRevoked(String msgId) {}
|
||||
}
|
||||
|
@ -3,23 +3,30 @@ import 'dart:convert';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
///
|
||||
///
|
||||
class ConversationManager {
|
||||
MethodChannel _channel;
|
||||
late ConversationListener conversationListener;
|
||||
|
||||
ConversationManager(this._channel);
|
||||
|
||||
/// listener[ConversationListener],Observe conversation changes
|
||||
///
|
||||
Future setConversationListener(ConversationListener listener) {
|
||||
this.conversationListener = listener;
|
||||
return _channel.invokeMethod('setConversationListener', _buildParam({}));
|
||||
}
|
||||
|
||||
/// get all conversations
|
||||
///
|
||||
Future<List<ConversationInfo>> getAllConversationList() => _channel
|
||||
.invokeMethod('getAllConversationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// sourceID: userID(single chat) ,groupID(group chat)
|
||||
/// sessionType: 1(single chat) ,2(group chat)
|
||||
/// sourceID: if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
/// sessionType: if it is a single chat, it value is 1. if it is a group chat, it value is 2
|
||||
///
|
||||
Future<ConversationInfo> getSingleConversation({
|
||||
required String sourceID,
|
||||
required String sessionType,
|
||||
@ -33,7 +40,8 @@ class ConversationManager {
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// ["single_1234","group_3434"]
|
||||
/// get conversation by id
|
||||
///
|
||||
Future<List<ConversationInfo>> getMultipleConversation({
|
||||
required List<String> conversationIDList,
|
||||
}) =>
|
||||
@ -45,6 +53,8 @@ class ConversationManager {
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// delete conversation by id
|
||||
///
|
||||
Future deleteConversation({
|
||||
required String conversationID,
|
||||
}) =>
|
||||
@ -56,6 +66,8 @@ class ConversationManager {
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
|
||||
/// set draft
|
||||
///
|
||||
Future setConversationDraft({
|
||||
required String conversationID,
|
||||
required String draftText,
|
||||
@ -69,6 +81,8 @@ class ConversationManager {
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
|
||||
/// pinned conversation
|
||||
///
|
||||
Future pinConversation({
|
||||
required String conversationID,
|
||||
required bool isPinned,
|
||||
|
@ -9,82 +9,113 @@ class FriendshipManager {
|
||||
|
||||
FriendshipManager(this._channel);
|
||||
|
||||
/// listener[FriendshipListener]
|
||||
///
|
||||
Future setFriendshipListener(FriendshipListener listener) {
|
||||
this.friendshipListener = listener;
|
||||
return _channel.invokeMethod('setFriendListener', _buildParam({}));
|
||||
}
|
||||
|
||||
/// get friend info by userid
|
||||
///
|
||||
Future<List<UserInfo>> getFriendsInfo({required List<String> uidList}) {
|
||||
return _channel
|
||||
.invokeMethod('getFriendsInfo', _buildParam({"uidList": uidList}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
/// send an friend application
|
||||
///
|
||||
Future<dynamic> addFriend({required String uid, required String reason}) {
|
||||
return _channel.invokeMethod(
|
||||
'addFriend', _buildParam({"uid": uid, "reqMessage": reason}));
|
||||
}
|
||||
|
||||
/// get all friend application
|
||||
/// including those initiated by you and sent to you by others
|
||||
Future<List<UserInfo>> getFriendApplicationList() {
|
||||
return _channel
|
||||
.invokeMethod('getFriendApplicationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
/// find all friends
|
||||
///
|
||||
Future<List<UserInfo>> getFriendList() {
|
||||
return _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
/// modify friend information, only [comment] can be modified
|
||||
///
|
||||
Future<dynamic> setFriendInfo({required UserInfo info}) {
|
||||
return _channel.invokeMethod('setFriendInfo', _buildParam(info.toJson()));
|
||||
}
|
||||
|
||||
/// add to blacklist
|
||||
///
|
||||
Future<dynamic> addToBlackList({required String uid}) {
|
||||
return _channel.invokeMethod('addToBlackList', _buildParam({"uid": uid}));
|
||||
}
|
||||
|
||||
/// find all blacklist
|
||||
///
|
||||
Future<List<UserInfo>> getBlackList() {
|
||||
return _channel
|
||||
.invokeMethod('getBlackList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
/// remove from blacklist
|
||||
///
|
||||
Future<dynamic> deleteFromBlackList({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'deleteFromBlackList', _buildParam({"uid": uid}));
|
||||
}
|
||||
|
||||
/// determine if there is a friendship by userId
|
||||
///
|
||||
Future<List<UserInfo>> checkFriend(List<String> uidList) {
|
||||
return _channel
|
||||
.invokeMethod('checkFriend', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
/// dissolve friendship from friend list
|
||||
///
|
||||
Future<dynamic> deleteFromFriendList({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'deleteFromFriendList', _buildParam({"uid": uid}));
|
||||
}
|
||||
|
||||
/// accept application of be friend
|
||||
///
|
||||
Future<dynamic> acceptFriendApplication({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'acceptFriendApplication', _buildParam({"uid": uid}));
|
||||
}
|
||||
|
||||
/// refuse application of be friend
|
||||
///
|
||||
Future<dynamic> refuseFriendApplication({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'refuseFriendApplication', _buildParam({"uid": uid}));
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
Future<dynamic> forceSyncFriendApplication() {
|
||||
return _channel.invokeMethod('forceSyncFriendApplication', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
Future<dynamic> forceSyncFriend() {
|
||||
return _channel.invokeMethod('forceSyncFriend', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> forceSyncBlackList() {
|
||||
return _channel.invokeMethod('forceSyncBlackList', _buildParam({}));
|
||||
}
|
||||
|
@ -10,11 +10,14 @@ class GroupManager {
|
||||
|
||||
GroupManager(this._channel);
|
||||
|
||||
/// listener[GroupListener]
|
||||
Future setGroupListener(GroupListener listener) {
|
||||
this.groupListener = listener;
|
||||
return _channel.invokeMethod('setGroupListener', _buildParam({}));
|
||||
}
|
||||
|
||||
/// invite friends into the group
|
||||
///
|
||||
Future<List<GroupInviteResult>> inviteUserToGroup({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
@ -33,6 +36,7 @@ class GroupManager {
|
||||
.toList());
|
||||
}
|
||||
|
||||
/// remove member from group
|
||||
Future<List<GroupInviteResult>> kickGroupMember({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
@ -51,6 +55,7 @@ class GroupManager {
|
||||
.toList());
|
||||
}
|
||||
|
||||
/// get group member's info
|
||||
Future<List<GroupMembersInfo>> getGroupMembersInfo({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
@ -67,8 +72,8 @@ class GroupManager {
|
||||
.toList());
|
||||
}
|
||||
|
||||
///filter 0: all user, 1: group owner, 2: administrator
|
||||
///begin index, pull and fill 0 for the first time
|
||||
/// filter 0: all user, 1: group owner, 2: administrator
|
||||
/// begin index, pull and fill 0 for the first time
|
||||
Future<GroupMembersList> getGroupMemberList({
|
||||
required String groupId,
|
||||
int filter = 0,
|
||||
@ -85,6 +90,7 @@ class GroupManager {
|
||||
.then((value) => GroupMembersList.fromJson(_formatJson(value)));
|
||||
}
|
||||
|
||||
/// find all groups you have joined
|
||||
Future<List<GroupInfo>> getJoinedGroupList() {
|
||||
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then(
|
||||
(value) => (_formatJson(value) as List)
|
||||
@ -92,11 +98,15 @@ class GroupManager {
|
||||
.toList());
|
||||
}
|
||||
|
||||
/// check
|
||||
Future<bool> isJoinedGroup({required String gid}) {
|
||||
return getJoinedGroupList()
|
||||
.then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
}
|
||||
|
||||
/// create a group
|
||||
/// @params groupInfo: Group information
|
||||
/// @params list[List<GroupMemberRole>]: Group members you invited
|
||||
Future<dynamic> createGroup({
|
||||
GroupInfo? groupInfo,
|
||||
required List<GroupMemberRole> list,
|
||||
@ -110,6 +120,7 @@ class GroupManager {
|
||||
/*.then((value) => _formatJson(value)['groupID'])*/
|
||||
}
|
||||
|
||||
/// Edit group information
|
||||
Future<dynamic> setGroupInfo({
|
||||
required GroupInfo groupInfo,
|
||||
}) {
|
||||
@ -120,6 +131,7 @@ class GroupManager {
|
||||
}));
|
||||
}
|
||||
|
||||
/// find group information by group id
|
||||
Future<List<GroupInfo>> getGroupsInfo({
|
||||
required List<String> gidList,
|
||||
}) {
|
||||
@ -131,6 +143,7 @@ class GroupManager {
|
||||
});
|
||||
}
|
||||
|
||||
/// Apply to join the group
|
||||
Future<dynamic> joinGroup({
|
||||
required String gid,
|
||||
String? reason,
|
||||
@ -143,6 +156,7 @@ class GroupManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> quitGroup({
|
||||
required String gid,
|
||||
}) {
|
||||
@ -153,6 +167,7 @@ class GroupManager {
|
||||
}));
|
||||
}
|
||||
|
||||
/// Give group permissions to others
|
||||
Future<dynamic> transferGroupOwner({
|
||||
required String gid,
|
||||
required String uid,
|
||||
@ -165,12 +180,14 @@ class GroupManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<GroupApplicationList> getGroupApplicationList() {
|
||||
return _channel
|
||||
.invokeMethod('getGroupApplicationList', _buildParam({}))
|
||||
.then((value) => GroupApplicationList.fromJson(_formatJson(value)));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> acceptGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
@ -183,6 +200,7 @@ class GroupManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> refuseGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
@ -195,18 +213,22 @@ class GroupManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future forceSyncApplyGroupRequest() {
|
||||
return _channel.invokeMethod('forceSyncApplyGroupRequest', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future forceSyncGroupRequest() {
|
||||
return _channel.invokeMethod('forceSyncGroupRequest', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future forceSyncJoinedGroup() {
|
||||
return _channel.invokeMethod('forceSyncJoinedGroup', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future forceSyncJoinedGroupMember() {
|
||||
return _channel.invokeMethod('forceSyncJoinedGroupMember', _buildParam({}));
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
@ -138,10 +139,11 @@ class IMManager {
|
||||
} else if (call.method == ListenerType.advancedMsgListener) {
|
||||
var type = call.arguments['type'];
|
||||
var id = call.arguments['data']['id'];
|
||||
var msg =
|
||||
Message.fromJson(_formatJson(call.arguments['data']['message']));
|
||||
var value = call.arguments['data']['message'];
|
||||
log('====================type:$type $value');
|
||||
switch (type) {
|
||||
case 'onRecvNewMessage':
|
||||
var msg = Message.fromJson(_formatJson(value));
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.onRecvNewMessage(msg);
|
||||
@ -151,14 +153,15 @@ class IMManager {
|
||||
case 'onRecvMessageRevoked':
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.onRecvMessageRevoked(msg);
|
||||
listener.onRecvMessageRevoked(value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'onRecvC2CReadReceipt':
|
||||
var info = HaveReadInfo.fromJson(_formatJson(value));
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.onRecvC2CReadReceipt(msg);
|
||||
listener.onRecvC2CReadReceipt(info);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -260,6 +263,12 @@ class IMManager {
|
||||
});
|
||||
}
|
||||
|
||||
/// init sdk
|
||||
///
|
||||
/// @params platform[IMPlatform]
|
||||
/// @params ipApi: api server ip address
|
||||
/// @params ipWs: websocket ip address
|
||||
/// @params dbPath: data storage directory
|
||||
Future<dynamic> initSDK({
|
||||
required int platform,
|
||||
required String ipApi,
|
||||
@ -276,10 +285,13 @@ class IMManager {
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> unInitSDK() {
|
||||
return _channel.invokeMethod('unInitSDK', _buildParam({}));
|
||||
}
|
||||
|
||||
/// login sdk
|
||||
///
|
||||
Future<dynamic> login({required String uid, required String token}) async {
|
||||
this.uid = uid;
|
||||
return _channel.invokeMethod(
|
||||
@ -288,38 +300,46 @@ class IMManager {
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> logout() {
|
||||
return _channel.invokeMethod('logout', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<int?> getLoginStatus() {
|
||||
return _channel.invokeMethod<int>('getLoginStatus', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<String?> getLoginUid() {
|
||||
return Future.value(uid);
|
||||
// return _channel.invokeMethod<String>('getLoginUid', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<UserInfo> getLoginUserInfo() {
|
||||
return getUsersInfo([uid]).then((list) => uInfo = list[0]);
|
||||
}
|
||||
|
||||
///
|
||||
Future<String?> setSelfInfo(UserInfo info) {
|
||||
return _channel.invokeMethod('setSelfInfo', _buildParam(info.toJson()));
|
||||
// .then((value) => UserInfo.fromJson(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<List<UserInfo>> getUsersInfo(List<String> uidList) {
|
||||
return _channel
|
||||
.invokeMethod('getUsersInfo', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> forceSyncLoginUerInfo(List<String> uidList) {
|
||||
return _channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> forceReConn() {
|
||||
return _channel.invokeMethod('forceReConn', _buildParam({}));
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
@ -11,6 +10,7 @@ class MessageManager {
|
||||
|
||||
MessageManager(this._channel);
|
||||
|
||||
///
|
||||
Future addAdvancedMsgListener(AdvancedMsgListener listener) {
|
||||
advancedMsgListeners.add(listener);
|
||||
return _channel.invokeMethod(
|
||||
@ -20,6 +20,7 @@ class MessageManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future removeAdvancedMsgListener(AdvancedMsgListener listener) {
|
||||
advancedMsgListeners.remove(listener);
|
||||
return _channel.invokeMethod(
|
||||
@ -29,11 +30,13 @@ class MessageManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
void setMsgSendProgressListener(MsgSendProgressListener listener) {
|
||||
msgSendProgressListener = listener;
|
||||
}
|
||||
|
||||
/*Future<Message> */
|
||||
/// send a message to user or to group
|
||||
/// userID: receiver's user ID
|
||||
Future<dynamic> sendMessage({
|
||||
required Message message,
|
||||
String? userID,
|
||||
@ -51,6 +54,8 @@ class MessageManager {
|
||||
/*.then((value) => _toObj(value))*/;
|
||||
}
|
||||
|
||||
/// find all history message
|
||||
/// userID: the user id of the chat partner
|
||||
Future<List<Message>> getHistoryMessageList({
|
||||
String? userID,
|
||||
String? groupID,
|
||||
@ -69,21 +74,28 @@ class MessageManager {
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
|
||||
/// revoke the sent information
|
||||
Future revokeMessage({required Message message}) {
|
||||
return _channel.invokeMethod(
|
||||
'revokeMessage', _buildParam(message.toJson()));
|
||||
}
|
||||
|
||||
/// delete message
|
||||
Future deleteMessageFromLocalStorage({required Message message}) {
|
||||
return _channel.invokeMethod(
|
||||
'deleteMessageFromLocalStorage', _buildParam(message.toJson()));
|
||||
}
|
||||
|
||||
///
|
||||
@deprecated
|
||||
Future deleteMessages({required List<Message> msgList}) {
|
||||
return _channel.invokeMethod('deleteMessages',
|
||||
_buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
|
||||
}
|
||||
|
||||
///
|
||||
/// @params userID: receiver's user ID
|
||||
/// @params sender: current user ID
|
||||
Future insertSingleMessageToLocalStorage({
|
||||
String? userID,
|
||||
Message? message,
|
||||
@ -98,6 +110,7 @@ class MessageManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future findMessages({required List<String> messageIDList}) {
|
||||
return _channel.invokeMethod(
|
||||
'findMessages',
|
||||
@ -106,22 +119,56 @@ class MessageManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
/// @params userID: receiver's userID
|
||||
Future<dynamic> markSingleMessageHasRead({required String userID}) {
|
||||
return _channel.invokeMethod(
|
||||
'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> markGroupMessageHasRead({required String groupID}) {
|
||||
return _channel.invokeMethod(
|
||||
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
|
||||
}
|
||||
|
||||
///
|
||||
/// @params userID: receiver's user ID
|
||||
Future markC2CMessageAsRead({
|
||||
required String userID,
|
||||
required List<String> messageIDList,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'markC2CMessageAsRead',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
"userID": userID,
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
/// @params userID: receiver's user ID
|
||||
/// @params status: default no
|
||||
Future typingStatusUpdate({
|
||||
required String userID,
|
||||
bool typing = false,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'typingStatusUpdate',
|
||||
_buildParam({
|
||||
"typing": typing ? 'yes' : 'no',
|
||||
"userID": userID,
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createTextMessage({required String text}) {
|
||||
return _channel
|
||||
.invokeMethod('createTextMessage', _buildParam({'text': text}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createTextAtMessage({
|
||||
required String text,
|
||||
required List<String> atUidList,
|
||||
@ -137,6 +184,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createImageMessage({required String imagePath}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
@ -146,6 +194,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createSoundMessage({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
@ -158,6 +207,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createVideoMessage({
|
||||
required String videoPath,
|
||||
required String videoType,
|
||||
@ -176,6 +226,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createFileMessage({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
@ -190,6 +241,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createMergerMessage({
|
||||
required List<Message> messageList,
|
||||
required String title,
|
||||
@ -206,6 +258,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createForwardMessage({required List<Message> messageList}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
@ -216,131 +269,16 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> getTotalUnreadMsgCount() {
|
||||
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
||||
}
|
||||
|
||||
///
|
||||
void forceSyncMsg() {
|
||||
_channel.invokeMethod('forceSyncMsg', _buildParam({}));
|
||||
}
|
||||
|
||||
Message createTextMessageV2({required String text}) {
|
||||
return _createMessage(contentType: MessageType.text)..content = text;
|
||||
}
|
||||
|
||||
Message createTextAtMessageV2({
|
||||
required String text,
|
||||
required List<String> atUidList,
|
||||
}) {
|
||||
var atElem = AtElem(
|
||||
text: text,
|
||||
atUserList: atUidList,
|
||||
isAtSelf: false,
|
||||
);
|
||||
return _createMessage(contentType: MessageType.at_text)
|
||||
..forceList = atUidList
|
||||
..atElem = atElem
|
||||
..content = jsonEncode(atElem);
|
||||
}
|
||||
|
||||
Message createImageMessageV2({
|
||||
required String imagePath,
|
||||
required String mineType,
|
||||
required int size,
|
||||
required int width,
|
||||
required int height,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.picture)
|
||||
..pictureElem = PictureElem(
|
||||
sourcePath: imagePath,
|
||||
sourcePicture: PictureInfo(
|
||||
type: mineType,
|
||||
size: size,
|
||||
width: width,
|
||||
height: height,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Message createSoundMessageV2({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
required int dataSize,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.voice)
|
||||
..soundElem = SoundElem(
|
||||
soundPath: soundPath,
|
||||
dataSize: dataSize,
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
Message createVideoMessageV2({
|
||||
required String videoPath,
|
||||
required String videoType,
|
||||
required int videoSize,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
required int snapshotSize,
|
||||
required int snapshotWidth,
|
||||
required int snapshotHeight,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.video)
|
||||
..videoElem = VideoElem(
|
||||
videoPath: videoPath,
|
||||
videoSize: videoSize,
|
||||
videoType: videoType,
|
||||
duration: duration,
|
||||
snapshotPath: snapshotPath,
|
||||
snapshotSize: snapshotSize,
|
||||
snapshotHeight: snapshotHeight,
|
||||
snapshotWidth: snapshotWidth,
|
||||
);
|
||||
}
|
||||
|
||||
Message createFileMessageV2({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
required int fileSize,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.file)
|
||||
..fileElem = FileElem(
|
||||
fileName: fileName,
|
||||
filePath: filePath,
|
||||
fileSize: fileSize,
|
||||
);
|
||||
}
|
||||
|
||||
/* Message createMergerMessageV2({
|
||||
required List<Message> messageList,
|
||||
required String title,
|
||||
required List<String> summaryList,
|
||||
}) {
|
||||
var message = _createMessage(contentType: MessageType.merger);
|
||||
return message;
|
||||
}
|
||||
|
||||
Message createForwardMessageV2({required List<Message> messageList}) {
|
||||
var message = _createMessage();
|
||||
return message;
|
||||
}*/
|
||||
|
||||
static Message _createMessage({required contentType}) {
|
||||
var now = DateTime.now();
|
||||
return Message(
|
||||
clientMsgID: 'client_msg_id_v2_${now.microsecondsSinceEpoch}',
|
||||
createTime: now.millisecond ~/ 1000,
|
||||
sendTime: now.millisecond ~/ 1000,
|
||||
// sessionType: 0,//请求为单人会话1,请求为群聊会话2
|
||||
msgFrom: 100,
|
||||
contentType: contentType,
|
||||
status: MessageStatus.sending,
|
||||
platformID: Platform.isAndroid ? IMPlatform.android : IMPlatform.ios,
|
||||
sendID: OpenIM.iMManager.uid,
|
||||
senderNickName: OpenIM.iMManager.uInfo.name,
|
||||
);
|
||||
}
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "messageManager";
|
||||
return param;
|
||||
|
123
lib/src/manager/v2/im_message_manager_v2.dart
Normal file
123
lib/src/manager/v2/im_message_manager_v2.dart
Normal file
@ -0,0 +1,123 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
extension MessageManagerV2 on MessageManager {
|
||||
Message createTextMessageV2({required String text}) {
|
||||
return _createMessage(contentType: MessageType.text)..content = text;
|
||||
}
|
||||
|
||||
Message createTextAtMessageV2({
|
||||
required String text,
|
||||
required List<String> atUidList,
|
||||
}) {
|
||||
var atElem = AtElem(
|
||||
text: text,
|
||||
atUserList: atUidList,
|
||||
isAtSelf: false,
|
||||
);
|
||||
return _createMessage(contentType: MessageType.at_text)
|
||||
..forceList = atUidList
|
||||
..atElem = atElem
|
||||
..content = jsonEncode(atElem);
|
||||
}
|
||||
|
||||
Message createImageMessageV2({
|
||||
required String imagePath,
|
||||
required String mineType,
|
||||
required int size,
|
||||
required int width,
|
||||
required int height,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.picture)
|
||||
..pictureElem = PictureElem(
|
||||
sourcePath: imagePath,
|
||||
sourcePicture: PictureInfo(
|
||||
type: mineType,
|
||||
size: size,
|
||||
width: width,
|
||||
height: height,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Message createSoundMessageV2({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
required int dataSize,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.voice)
|
||||
..soundElem = SoundElem(
|
||||
soundPath: soundPath,
|
||||
dataSize: dataSize,
|
||||
duration: duration,
|
||||
);
|
||||
}
|
||||
|
||||
Message createVideoMessageV2({
|
||||
required String videoPath,
|
||||
required String videoType,
|
||||
required int videoSize,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
required int snapshotSize,
|
||||
required int snapshotWidth,
|
||||
required int snapshotHeight,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.video)
|
||||
..videoElem = VideoElem(
|
||||
videoPath: videoPath,
|
||||
videoSize: videoSize,
|
||||
videoType: videoType,
|
||||
duration: duration,
|
||||
snapshotPath: snapshotPath,
|
||||
snapshotSize: snapshotSize,
|
||||
snapshotHeight: snapshotHeight,
|
||||
snapshotWidth: snapshotWidth,
|
||||
);
|
||||
}
|
||||
|
||||
Message createFileMessageV2({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
required int fileSize,
|
||||
}) {
|
||||
return _createMessage(contentType: MessageType.file)
|
||||
..fileElem = FileElem(
|
||||
fileName: fileName,
|
||||
filePath: filePath,
|
||||
fileSize: fileSize,
|
||||
);
|
||||
}
|
||||
|
||||
/* Message createMergerMessageV2({
|
||||
required List<Message> messageList,
|
||||
required String title,
|
||||
required List<String> summaryList,
|
||||
}) {
|
||||
var message = _createMessage(contentType: MessageType.merger);
|
||||
return message;
|
||||
}
|
||||
|
||||
Message createForwardMessageV2({required List<Message> messageList}) {
|
||||
var message = _createMessage();
|
||||
return message;
|
||||
}*/
|
||||
|
||||
static Message _createMessage({required contentType}) {
|
||||
var now = DateTime.now();
|
||||
return Message(
|
||||
clientMsgID: 'flutter_client_${now.microsecondsSinceEpoch}',
|
||||
createTime: now.millisecond ~/ 1000,
|
||||
sendTime: now.millisecond ~/ 1000,
|
||||
// sessionType: 0,//请求为单人会话1,请求为群聊会话2
|
||||
msgFrom: 100,
|
||||
contentType: contentType,
|
||||
status: MessageStatus.sending,
|
||||
platformID: Platform.isAndroid ? IMPlatform.android : IMPlatform.ios,
|
||||
sendID: OpenIM.iMManager.uid,
|
||||
senderNickName: OpenIM.iMManager.uInfo.name,
|
||||
);
|
||||
}
|
||||
}
|
@ -368,43 +368,41 @@ class AtElem {
|
||||
}
|
||||
}
|
||||
|
||||
class RevokeMessage {
|
||||
String? serverMsgID;
|
||||
String? sendID;
|
||||
String? senderNickname;
|
||||
String? recvID;
|
||||
String? groupID;
|
||||
class HaveReadInfo {
|
||||
String? uid;
|
||||
List<String>? msgIDList;
|
||||
int? readTime;
|
||||
int? msgFrom;
|
||||
int? contentType;
|
||||
int? sendTime;
|
||||
int? sessionType;
|
||||
|
||||
RevokeMessage(
|
||||
{this.serverMsgID,
|
||||
this.sendID,
|
||||
this.senderNickname,
|
||||
this.recvID,
|
||||
this.groupID,
|
||||
HaveReadInfo(
|
||||
{this.uid,
|
||||
this.msgIDList,
|
||||
this.readTime,
|
||||
this.msgFrom,
|
||||
this.contentType,
|
||||
this.sendTime});
|
||||
this.sessionType});
|
||||
|
||||
RevokeMessage.fromJson(Map<String, dynamic> json) {
|
||||
serverMsgID = json['serverMsgID'];
|
||||
sendID = json['sendID'];
|
||||
senderNickname = json['senderNickname'];
|
||||
recvID = json['recvID'];
|
||||
groupID = json['groupID'];
|
||||
HaveReadInfo.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
if (json['msgIDList'] is List) {
|
||||
msgIDList = (json['msgIDList'] as List).map((e) => '$e').toList();
|
||||
}
|
||||
readTime = json['readTime'];
|
||||
msgFrom = json['msgFrom'];
|
||||
contentType = json['contentType'];
|
||||
sendTime = json['sendTime'];
|
||||
sessionType = json['sessionType'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['serverMsgID'] = this.serverMsgID;
|
||||
data['sendID'] = this.sendID;
|
||||
data['senderNickname'] = this.senderNickname;
|
||||
data['recvID'] = this.recvID;
|
||||
data['groupID'] = this.groupID;
|
||||
data['uid'] = this.uid;
|
||||
data['msgIDList'] = this.msgIDList;
|
||||
data['readTime'] = this.readTime;
|
||||
data['msgFrom'] = this.msgFrom;
|
||||
data['contentType'] = this.contentType;
|
||||
data['sendTime'] = this.sendTime;
|
||||
data['sessionType'] = this.sessionType;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user