new version sdk
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
library flutter_openim_sdk;
|
||||
|
||||
export 'src/enum/conversation_type.dart';
|
||||
export 'src/enum/group_role.dart';
|
||||
export 'src/enum/group_role_level.dart';
|
||||
export 'src/enum/im_platform.dart';
|
||||
export 'src/enum/listener_type.dart';
|
||||
export 'src/enum/message_status.dart';
|
||||
@@ -27,8 +27,10 @@ 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/im_user_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';
|
||||
export 'src/utils.dart';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class ConversationType {
|
||||
static const single_chat = 1;
|
||||
static const group_chat = 2;
|
||||
static const single = 1;
|
||||
static const group = 2;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class GroupRole {
|
||||
static const member = 0;
|
||||
static const owner = 1;
|
||||
static const admin = 2;
|
||||
}
|
||||
7
lib/src/enum/group_role_level.dart
Normal file
7
lib/src/enum/group_role_level.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
/// 1 ordinary member, 2 group owners, 3 administrators
|
||||
/// 1普通成员, 2群主,3管理员
|
||||
class GroupRoleLevel {
|
||||
static const member = 1;
|
||||
static const owner = 2;
|
||||
static const admin = 3;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ abstract class AdvancedMsgListener {
|
||||
void recvNewMessage(Message msg);
|
||||
|
||||
/// Message read receipt
|
||||
void recvC2CReadReceipt(List<HaveReadInfo> list);
|
||||
void recvC2CReadReceipt(List<ReadReceiptInfo> list);
|
||||
|
||||
/// A friend withdrew a message
|
||||
void recvMessageRevoked(String msgId);
|
||||
|
||||
@@ -9,10 +9,6 @@ abstract class GroupListener {
|
||||
|
||||
void groupMemberDeleted(GroupMembersInfo info);
|
||||
|
||||
void receiveJoinGroupApplicationAdded(GroupApplicationInfo info);
|
||||
|
||||
void receiveJoinGroupApplicationDeleted(GroupApplicationInfo info);
|
||||
|
||||
void groupApplicationAdded(GroupApplicationInfo info);
|
||||
|
||||
void groupApplicationDeleted(GroupApplicationInfo info);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
class OnAdvancedMsgListener extends AdvancedMsgListener {
|
||||
Function(List<HaveReadInfo> list)? onRecvC2CReadReceipt;
|
||||
Function(List<ReadReceiptInfo> list)? onRecvC2CReadReceipt;
|
||||
Function(String msgId)? onRecvMessageRevoked;
|
||||
Function(Message msg)? onRecvNewMessage;
|
||||
|
||||
@@ -12,7 +12,7 @@ class OnAdvancedMsgListener extends AdvancedMsgListener {
|
||||
});
|
||||
|
||||
@override
|
||||
void recvC2CReadReceipt(List<HaveReadInfo> list) {
|
||||
void recvC2CReadReceipt(List<ReadReceiptInfo> list) {
|
||||
if (null != onRecvC2CReadReceipt) onRecvC2CReadReceipt!(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
/// 申请添加好友:
|
||||
/// 主动申请者收到 OnFriendApplicationAdded
|
||||
/// 被添加者收到 OnFriendApplicationAdded
|
||||
///
|
||||
/// 同意好友申请:
|
||||
/// 操作者收到 OnFriendApplicationAccepted OnFriendAdded
|
||||
/// 申请者收到 OnFriendApplicationAccepted OnFriendAdded
|
||||
///
|
||||
/// 好友拒绝申请:
|
||||
/// 操作者收到 OnFriendApplicationRejected
|
||||
/// 申请者收到 OnFriendApplicationRejected
|
||||
///
|
||||
/// 删除好友:
|
||||
/// 操作者收到 OnFriendDeleted
|
||||
///
|
||||
/// 修改备注:
|
||||
/// 操作者收到 OnFriendInfoChanged
|
||||
///
|
||||
/// 添加黑名单:
|
||||
/// 操作者收到 OnBlacklistAdded;
|
||||
///
|
||||
/// 移除黑名单:
|
||||
/// 操作者收到 OnBlacklistDeleted
|
||||
class OnFriendshipListener extends FriendshipListener {
|
||||
Function(FriendApplicationInfo i)? onFriendApplicationAdded;
|
||||
Function(FriendApplicationInfo i)? onFriendApplicationDeleted;
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
/// 创建群:
|
||||
/// 初始成员收到 OnJoinedGroupAdded
|
||||
///
|
||||
/// 退出群:
|
||||
/// 退出者收到 OnJoinedGroupDeleted
|
||||
/// 群成员收到 OnGroupMemberDeleted
|
||||
///
|
||||
/// 踢出群:
|
||||
/// 被踢者收到 OnJoinedGroupDeleted
|
||||
/// 群成员收到 OnGroupMemberDeleted
|
||||
///
|
||||
/// 邀请进群:
|
||||
/// 被邀请者收到 OnJoinedGroupAdded
|
||||
/// 群成员(不包括被邀请者)收到 OnGroupMemberAdded
|
||||
///
|
||||
/// 申请加群:
|
||||
/// 申请者收到 OnGroupApplicationAdded
|
||||
/// 群主+管理员收到 OnReceiveJoinGroupApplicationAdded
|
||||
///
|
||||
/// 同意进群:
|
||||
/// 申请者收到 OnJoinedGroupAdded OnGroupApplicationAccepted
|
||||
/// 群成员(不包括申请者)收到 OnGroupMemberAdded
|
||||
/// 审批者(群主或者管理员)收到 OnGroupMemberAdded OnGroupApplicationAccepted
|
||||
///
|
||||
/// 拒绝进群:
|
||||
/// 申请者收到 OnGroupApplicationRejected;
|
||||
/// 审批者(群主或者管理员)收到 OnGroupApplicationRejected
|
||||
///
|
||||
/// 修改群资料:
|
||||
/// 群成员收到 OnGroupInfoChanged
|
||||
class OnGroupListener extends GroupListener {
|
||||
Function(GroupApplicationInfo info)? onGroupApplicationAccepted;
|
||||
Function(GroupApplicationInfo info)? onGroupApplicationAdded;
|
||||
@@ -41,8 +11,6 @@ class OnGroupListener extends GroupListener {
|
||||
Function(GroupMembersInfo info)? onGroupMemberInfoChanged;
|
||||
Function(GroupInfo info)? onJoinedGroupAdded;
|
||||
Function(GroupInfo info)? onJoinedGroupDeleted;
|
||||
Function(GroupApplicationInfo info)? onReceiveJoinGroupApplicationAdded;
|
||||
Function(GroupApplicationInfo info)? onReceiveJoinGroupApplicationDeleted;
|
||||
|
||||
OnGroupListener({
|
||||
this.onGroupApplicationAccepted,
|
||||
@@ -55,8 +23,6 @@ class OnGroupListener extends GroupListener {
|
||||
this.onGroupMemberInfoChanged,
|
||||
this.onJoinedGroupAdded,
|
||||
this.onJoinedGroupDeleted,
|
||||
this.onReceiveJoinGroupApplicationAdded,
|
||||
this.onReceiveJoinGroupApplicationDeleted,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -108,14 +74,4 @@ class OnGroupListener extends GroupListener {
|
||||
void joinedGroupDeleted(GroupInfo info) {
|
||||
onJoinedGroupDeleted?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void receiveJoinGroupApplicationAdded(GroupApplicationInfo info) {
|
||||
onReceiveJoinGroupApplicationAdded?.call(info);
|
||||
}
|
||||
|
||||
@override
|
||||
void receiveJoinGroupApplicationDeleted(GroupApplicationInfo info) {
|
||||
onReceiveJoinGroupApplicationDeleted?.call(info);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
///
|
||||
///
|
||||
class ConversationManager {
|
||||
MethodChannel _channel;
|
||||
late ConversationListener conversationListener;
|
||||
@@ -26,9 +22,10 @@ class ConversationManager {
|
||||
.invokeMethod(
|
||||
'getAllConversationList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Paging to get conversation
|
||||
/// 分页获取会话
|
||||
@@ -43,9 +40,10 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Get a conversation, if it doesn't exist it will be created automatically
|
||||
/// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
@@ -64,9 +62,10 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
"sourceID": sourceID,
|
||||
"sessionType": sessionType,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) =>
|
||||
Utils.toObj(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Get conversation list by id list
|
||||
/// 获取多个会话
|
||||
@@ -79,9 +78,10 @@ class ConversationManager {
|
||||
'getMultipleConversation',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Delete conversation by id
|
||||
/// 删除会话
|
||||
@@ -89,14 +89,12 @@ class ConversationManager {
|
||||
required String conversationID,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'deleteConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
_channel.invokeMethod(
|
||||
'deleteConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Set draft
|
||||
/// 设置会话草稿
|
||||
@@ -105,15 +103,13 @@ class ConversationManager {
|
||||
required String draftText,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'setConversationDraft',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"draftText": draftText,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
_channel.invokeMethod(
|
||||
'setConversationDraft',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"draftText": draftText,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Pinned conversation
|
||||
/// 置顶会话
|
||||
@@ -122,18 +118,14 @@ class ConversationManager {
|
||||
required bool isPinned,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'pinConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"isPinned": isPinned,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _printValue(value));
|
||||
_channel.invokeMethod(
|
||||
'pinConversation',
|
||||
_buildParam({
|
||||
"conversationID": conversationID,
|
||||
"isPinned": isPinned,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Mark single chat messages as read
|
||||
/// 标记单聊已读
|
||||
// Future<dynamic> markSingleMessageHasRead({required String userID}) =>
|
||||
// _channel.invokeMethod(
|
||||
// 'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
@@ -148,7 +140,7 @@ class ConversationManager {
|
||||
'markGroupMessageHasRead',
|
||||
_buildParam({
|
||||
'groupID': groupID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Get the total number of unread messages
|
||||
@@ -159,7 +151,7 @@ class ConversationManager {
|
||||
_channel.invokeMethod(
|
||||
'getTotalUnreadMsgCount',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Query conversation id
|
||||
@@ -180,9 +172,9 @@ class ConversationManager {
|
||||
}));
|
||||
|
||||
/// Message Do Not Disturb
|
||||
/// [status] 1: Do not receive messages. 2: Do not notify when messages are received. 0: Normal.
|
||||
/// [status] 0: Normal. 1: Do not receive messages. 2: Do not notify when messages are received.
|
||||
/// 消息免打扰设置
|
||||
/// [status] 1:不接受消息;2:接受在线消息不接受离线消息;3:正常
|
||||
/// [status] 0:正常;1:不接受消息;2:接受在线消息不接受离线消息;
|
||||
Future<dynamic> setConversationRecvMessageOpt({
|
||||
required List<String> conversationIDList,
|
||||
required int status,
|
||||
@@ -193,7 +185,7 @@ class ConversationManager {
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"status": status,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Message Do Not Disturb
|
||||
@@ -208,12 +200,12 @@ class ConversationManager {
|
||||
'getConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
.then((value) => Utils.toListMap(value));
|
||||
|
||||
/// Custom sort for conversation list
|
||||
/// 会话列表自定义排序规则
|
||||
/// 会话列表自定义排序规则。
|
||||
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
|
||||
..sort((a, b) {
|
||||
if ((a.isPinned == true && b.isPinned == true) ||
|
||||
@@ -242,23 +234,4 @@ class ConversationManager {
|
||||
param["ManagerName"] = "conversationManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<ConversationInfo> _toList(String? value) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <ConversationInfo>[];
|
||||
return (list as List).map((e) => ConversationInfo.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
static ConversationInfo _toObj(String value) =>
|
||||
ConversationInfo.fromJson(_formatJson(value));
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
@@ -27,9 +25,9 @@ class FriendshipManager {
|
||||
'getFriendsInfo',
|
||||
_buildParam({
|
||||
"uidList": uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
|
||||
|
||||
/// Send an friend application
|
||||
/// 发送一个好友请求
|
||||
@@ -43,7 +41,7 @@ class FriendshipManager {
|
||||
_buildParam({
|
||||
"toUserID": uid,
|
||||
"reqMsg": reason,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Get someone's request to add me as a friend
|
||||
@@ -54,10 +52,10 @@ class FriendshipManager {
|
||||
.invokeMethod(
|
||||
'getRecvFriendApplicationList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
_toList(value, (v) => FriendApplicationInfo.fromJson(v.cast())));
|
||||
Utils.toList(value, (v) => FriendApplicationInfo.fromJson(v)));
|
||||
|
||||
/// Get friend requests from me
|
||||
/// 获取我发出的好友申请
|
||||
@@ -67,10 +65,10 @@ class FriendshipManager {
|
||||
.invokeMethod(
|
||||
'getSendFriendApplicationList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
_toList(value, (v) => FriendApplicationInfo.fromJson(v.cast())));
|
||||
Utils.toList(value, (v) => FriendApplicationInfo.fromJson(v)));
|
||||
|
||||
/// Find all friends including those who have been added to the blacklist
|
||||
/// 获取好友列表包含已拉入黑名单的好友
|
||||
@@ -78,9 +76,9 @@ class FriendshipManager {
|
||||
.invokeMethod(
|
||||
'getFriendList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
|
||||
|
||||
/// Find all friends including those who have been added to the blacklist
|
||||
/// 获取好友列表
|
||||
@@ -88,11 +86,11 @@ class FriendshipManager {
|
||||
.invokeMethod(
|
||||
'getFriendList',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toListMap(value));
|
||||
.then((value) => Utils.toListMap(value));
|
||||
|
||||
/// Modify friend information, only [comment] can be modified
|
||||
/// Modify friend remark name
|
||||
/// 设置好友备注
|
||||
Future<dynamic> setFriendRemark({
|
||||
required String uid,
|
||||
@@ -104,7 +102,7 @@ class FriendshipManager {
|
||||
_buildParam({
|
||||
'toUserID': uid,
|
||||
'remark': remark,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Add friends to blacklist
|
||||
@@ -117,7 +115,7 @@ class FriendshipManager {
|
||||
'addBlacklist',
|
||||
_buildParam({
|
||||
"uid": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Find all blacklist
|
||||
@@ -126,9 +124,9 @@ class FriendshipManager {
|
||||
.invokeMethod(
|
||||
'getBlacklist',
|
||||
_buildParam({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
|
||||
|
||||
/// Remove from blacklist
|
||||
/// 从黑名单移除
|
||||
@@ -140,7 +138,7 @@ class FriendshipManager {
|
||||
'removeBlacklist',
|
||||
_buildParam({
|
||||
"uid": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Determine if there is a friendship by userId
|
||||
@@ -154,10 +152,10 @@ class FriendshipManager {
|
||||
'checkFriend',
|
||||
_buildParam({
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
_toList(value, (v) => FriendshipInfo.fromJson(v.cast())));
|
||||
Utils.toList(value, (v) => FriendshipInfo.fromJson(v)));
|
||||
|
||||
/// Dissolve friendship from friend list
|
||||
/// 删除好友
|
||||
@@ -169,7 +167,7 @@ class FriendshipManager {
|
||||
'deleteFriend',
|
||||
_buildParam({
|
||||
"uid": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Accept application of be friend
|
||||
@@ -184,7 +182,7 @@ class FriendshipManager {
|
||||
_buildParam({
|
||||
"toUserID": uid,
|
||||
"handleMsg": handleMsg,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Refuse application of be friend
|
||||
@@ -199,49 +197,11 @@ class FriendshipManager {
|
||||
_buildParam({
|
||||
"toUserID": uid,
|
||||
"handleMsg": handleMsg,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
///
|
||||
// Future<dynamic> forceSyncFriendApplication() {
|
||||
// return _channel.invokeMethod('forceSyncFriendApplication', _buildParam({}));
|
||||
// }
|
||||
|
||||
///
|
||||
// Future<dynamic> forceSyncFriend() {
|
||||
// return _channel.invokeMethod('forceSyncFriend', _buildParam({}));
|
||||
// }
|
||||
|
||||
///
|
||||
// Future<dynamic> forceSyncBlackList() {
|
||||
// return _channel.invokeMethod('forceSyncBlackList', _buildParam({}));
|
||||
// }
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "friendshipManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<T> _toList<T>(String? value, T f(Map map)) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <T>[];
|
||||
return (list as List).map((e) => f(e)).toList();
|
||||
}
|
||||
|
||||
static List<dynamic> _toListMap(String? value) {
|
||||
var list = _formatJson(value);
|
||||
return list;
|
||||
}
|
||||
|
||||
// static UserInfo _toObj(String value) => UserInfo.fromJson(_formatJson(value));
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
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';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
class GroupManager {
|
||||
MethodChannel _channel;
|
||||
@@ -32,11 +29,10 @@ class GroupManager {
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
|
||||
|
||||
/// Remove member from group
|
||||
/// 移除组成员
|
||||
@@ -53,11 +49,10 @@ class GroupManager {
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
|
||||
|
||||
/// Get group member's info
|
||||
/// 查询组成员资料
|
||||
@@ -72,11 +67,10 @@ class GroupManager {
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'uidList': uidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
|
||||
|
||||
/// Get the list of group members
|
||||
/// 分页获取组成员列表
|
||||
@@ -95,15 +89,14 @@ class GroupManager {
|
||||
'filter': filter,
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
|
||||
|
||||
/// Get the list of group members
|
||||
/// 分页获取组成员列表
|
||||
Future<dynamic> getGroupMemberListMap({
|
||||
Future<List<dynamic>> getGroupMemberListMap({
|
||||
required String groupId,
|
||||
int filter = 0,
|
||||
int offset = 0,
|
||||
@@ -118,9 +111,9 @@ class GroupManager {
|
||||
'filter': filter,
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
.then((value) => Utils.toListMap(value));
|
||||
|
||||
/// Find all groups you have joined
|
||||
/// 查询已加入的组列表
|
||||
@@ -128,11 +121,9 @@ class GroupManager {
|
||||
.invokeMethod(
|
||||
'getJoinedGroupList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInfo.fromJson(e))
|
||||
.toList());
|
||||
.then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
|
||||
|
||||
/// Find all groups you have joined
|
||||
/// 查询已加入的组列表
|
||||
@@ -140,9 +131,9 @@ class GroupManager {
|
||||
.invokeMethod(
|
||||
'getJoinedGroupList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
.then((value) => Utils.toListMap(value));
|
||||
|
||||
/// Check if you are a member of the group
|
||||
/// 检查是否已加入组
|
||||
@@ -151,7 +142,7 @@ class GroupManager {
|
||||
String? operationID,
|
||||
}) =>
|
||||
getJoinedGroupList(
|
||||
operationID: _checkOperationID(operationID),
|
||||
operationID: Utils.checkOperationID(operationID),
|
||||
).then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
|
||||
/// Create a group
|
||||
@@ -179,9 +170,10 @@ class GroupManager {
|
||||
"ex": ex,
|
||||
},
|
||||
'memberList': list.map((e) => e.toJson()).toList(),
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => GroupInfo.fromJson(_formatJson(value)));
|
||||
.then(
|
||||
(value) => Utils.toObj(value, (map) => GroupInfo.fromJson(map)));
|
||||
|
||||
/// Edit group information
|
||||
/// 编辑组资料
|
||||
@@ -206,7 +198,7 @@ class GroupManager {
|
||||
"faceURL": faceUrl,
|
||||
"ex": ex,
|
||||
},
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Find group information by group id
|
||||
@@ -220,12 +212,10 @@ class GroupManager {
|
||||
'getGroupsInfo',
|
||||
_buildParam({
|
||||
'gidList': gidList,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) {
|
||||
List list = _formatJson(value);
|
||||
return list.map((e) => GroupInfo.fromJson(e)).toList();
|
||||
});
|
||||
.then(
|
||||
(value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
|
||||
|
||||
/// Apply to join the group
|
||||
/// 申请加入组,需要通过管理员同意。
|
||||
@@ -239,7 +229,7 @@ class GroupManager {
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'reason': reason,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Leave group
|
||||
@@ -252,7 +242,7 @@ class GroupManager {
|
||||
'quitGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Give group permissions to others
|
||||
@@ -267,7 +257,7 @@ class GroupManager {
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// As the group owner or administrator, get the list of received group members' applications to join the group.
|
||||
@@ -278,11 +268,10 @@ class GroupManager {
|
||||
.invokeMethod(
|
||||
'getRecvGroupApplicationList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupApplicationInfo.fromJson(e))
|
||||
.toList());
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
|
||||
|
||||
/// Get the record of the group membership application issued by yourself
|
||||
/// 获取自己发出的入群申请记录
|
||||
@@ -292,11 +281,10 @@ class GroupManager {
|
||||
.invokeMethod(
|
||||
'getSendGroupApplicationList',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupApplicationInfo.fromJson(e))
|
||||
.toList());
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
|
||||
|
||||
/// Accept group application
|
||||
/// 管理员或者群主同意某人进入某群
|
||||
@@ -312,7 +300,7 @@ class GroupManager {
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
'handleMsg': handleMsg,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Refuse group application
|
||||
@@ -329,41 +317,11 @@ class GroupManager {
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
'handleMsg': handleMsg,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
///
|
||||
// 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({}));
|
||||
// }
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "groupManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_openim_sdk/src/manager/im_user_manager.dart';
|
||||
|
||||
class IMManager {
|
||||
MethodChannel _channel;
|
||||
@@ -61,7 +59,7 @@ class IMManager {
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onSelfInfoUpdated':
|
||||
uInfo = UserInfo.fromJson(_formatJson(data));
|
||||
uInfo = Utils.toObj(data, (map) => UserInfo.fromJson(map));
|
||||
userManager.userListener.selfInfoUpdated(uInfo);
|
||||
break;
|
||||
}
|
||||
@@ -70,53 +68,52 @@ class IMManager {
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onGroupApplicationAccepted':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.groupListener.groupApplicationAccepted(i);
|
||||
break;
|
||||
case 'onGroupApplicationAdded':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.groupListener.groupApplicationAdded(i);
|
||||
break;
|
||||
case 'onGroupApplicationDeleted':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.groupListener.groupApplicationDeleted(i);
|
||||
break;
|
||||
case 'onGroupApplicationRejected':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.groupListener.groupApplicationRejected(i);
|
||||
break;
|
||||
case 'onGroupInfoChanged':
|
||||
final i = GroupInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(data, (map) => GroupInfo.fromJson(map));
|
||||
groupManager.groupListener.groupInfoChanged(i);
|
||||
break;
|
||||
case 'onGroupMemberAdded':
|
||||
final i = GroupMembersInfo.fromJson(_formatJson(data));
|
||||
final i =
|
||||
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
groupManager.groupListener.groupMemberAdded(i);
|
||||
break;
|
||||
case 'onGroupMemberDeleted':
|
||||
final i = GroupMembersInfo.fromJson(_formatJson(data));
|
||||
final i =
|
||||
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
groupManager.groupListener.groupMemberDeleted(i);
|
||||
break;
|
||||
case 'onGroupMemberInfoChanged':
|
||||
final i = GroupMembersInfo.fromJson(_formatJson(data));
|
||||
final i =
|
||||
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
groupManager.groupListener.groupMemberInfoChanged(i);
|
||||
break;
|
||||
case 'onJoinedGroupAdded':
|
||||
final i = GroupInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(data, (map) => GroupInfo.fromJson(map));
|
||||
groupManager.groupListener.joinedGroupAdded(i);
|
||||
break;
|
||||
case 'onJoinedGroupDeleted':
|
||||
final i = GroupInfo.fromJson(_formatJson(data));
|
||||
final i = Utils.toObj(data, (map) => GroupInfo.fromJson(map));
|
||||
groupManager.groupListener.joinedGroupDeleted(i);
|
||||
break;
|
||||
case 'onReceiveJoinGroupApplicationAdded':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.receiveJoinGroupApplicationAdded(i);
|
||||
break;
|
||||
case 'onReceiveJoinGroupApplicationDeleted':
|
||||
final i = GroupApplicationInfo.fromJson(_formatJson(data));
|
||||
groupManager.groupListener.receiveJoinGroupApplicationDeleted(i);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.advancedMsgListener) {
|
||||
var type = call.arguments['type'];
|
||||
@@ -124,7 +121,7 @@ class IMManager {
|
||||
switch (type) {
|
||||
case 'onRecvNewMessage':
|
||||
var value = call.arguments['data']['newMessage'];
|
||||
var msg = Message.fromJson(_formatJson(value));
|
||||
final msg = Utils.toObj(value, (map) => Message.fromJson(map));
|
||||
messageManager.advancedMsgListener.recvNewMessage(msg);
|
||||
break;
|
||||
case 'onRecvMessageRevoked':
|
||||
@@ -133,8 +130,8 @@ class IMManager {
|
||||
break;
|
||||
case 'onRecvC2CReadReceipt':
|
||||
var value = call.arguments['data']['haveReadMessage'];
|
||||
var l = _formatJson(value) as List;
|
||||
var list = l.map((e) => HaveReadInfo.fromJson(e)).toList();
|
||||
var list =
|
||||
Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map));
|
||||
messageManager.advancedMsgListener.recvC2CReadReceipt(list);
|
||||
break;
|
||||
}
|
||||
@@ -166,21 +163,13 @@ class IMManager {
|
||||
conversationManager.conversationListener.syncServerFailed();
|
||||
break;
|
||||
case 'onNewConversation':
|
||||
List<ConversationInfo> list = List.empty(growable: true);
|
||||
if (null != data) {
|
||||
list = (_formatJson(data) as List)
|
||||
.map((e) => ConversationInfo.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
var list =
|
||||
Utils.toList(data, (map) => ConversationInfo.fromJson(map));
|
||||
conversationManager.conversationListener.newConversation(list);
|
||||
break;
|
||||
case 'onConversationChanged':
|
||||
List<ConversationInfo> list = List.empty(growable: true);
|
||||
if (null != data) {
|
||||
list = (_formatJson(data) as List)
|
||||
.map((e) => ConversationInfo.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
var list =
|
||||
Utils.toList(data, (map) => ConversationInfo.fromJson(map));
|
||||
conversationManager.conversationListener
|
||||
.conversationChanged(list);
|
||||
break;
|
||||
@@ -195,46 +184,50 @@ class IMManager {
|
||||
|
||||
switch (type) {
|
||||
case 'onBlacklistAdded':
|
||||
final u = BlacklistInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(data, (map) => BlacklistInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.blacklistAdded(u);
|
||||
break;
|
||||
case 'onBlacklistDeleted':
|
||||
final u = BlacklistInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(data, (map) => BlacklistInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.blacklistDeleted(u);
|
||||
break;
|
||||
case 'onFriendApplicationAccepted':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendApplicationAccepted(u);
|
||||
break;
|
||||
case 'onFriendApplicationAdded':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendApplicationAdded(u);
|
||||
break;
|
||||
case 'onFriendApplicationDeleted':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendApplicationDeleted(u);
|
||||
break;
|
||||
case 'onFriendApplicationListRejected':
|
||||
final u = FriendApplicationInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendApplicationRejected(u);
|
||||
break;
|
||||
case 'onFriendInfoChanged':
|
||||
final u = FriendInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(data, (map) => FriendInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendInfoChanged(u);
|
||||
break;
|
||||
case 'onFriendAdded':
|
||||
final u = FriendInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(data, (map) => FriendInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendAdded(u);
|
||||
break;
|
||||
case 'onFriendDeleted':
|
||||
final u = FriendInfo.fromJson(_formatJson(data));
|
||||
final u = Utils.toObj(data, (map) => FriendInfo.fromJson(map));
|
||||
friendshipManager.friendshipListener.friendDeleted(u);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
print(
|
||||
"回调失败了,数据类型异常。$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}");
|
||||
"回调失败了。$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}");
|
||||
}
|
||||
return Future.value(null);
|
||||
});
|
||||
@@ -242,14 +235,16 @@ class IMManager {
|
||||
|
||||
/// Initialize SDK
|
||||
///
|
||||
/// [platform] Refer to [IMPlatform]
|
||||
/// [apiAddr] Api server ip address
|
||||
/// [wsAddr] WebSocket ip address
|
||||
/// [dataDir] Data storage directory
|
||||
/// [platform] platform number [IMPlatform]
|
||||
/// [apiAddr] api server ip address
|
||||
/// [wsAddr] webSocket ip address
|
||||
/// [dataDir] data storage directory
|
||||
///
|
||||
/// 初始化SDK
|
||||
/// [platform] 平台编号[IMPlatform]
|
||||
/// [apiAddr] SDK api地址
|
||||
/// [wsAddr] SDK websocket地址
|
||||
///
|
||||
/// [platform] 平台编号[IMPlatform]
|
||||
/// [apiAddr] SDK api地址
|
||||
/// [wsAddr] SDK websocket地址
|
||||
/// [dataDir] SDK数据库存储目录
|
||||
Future<dynamic> initSDK({
|
||||
required int platform,
|
||||
@@ -272,7 +267,7 @@ class IMManager {
|
||||
"data_dir": dataDir,
|
||||
"log_level": logLevel,
|
||||
"object_storage": objectStorage,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
},
|
||||
));
|
||||
}
|
||||
@@ -294,7 +289,7 @@ class IMManager {
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'token': token,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
this.isLogined = true;
|
||||
@@ -309,7 +304,7 @@ class IMManager {
|
||||
var value = await _channel.invokeMethod(
|
||||
'logout',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
this.isLogined = false;
|
||||
return value;
|
||||
@@ -331,14 +326,4 @@ class IMManager {
|
||||
param["ManagerName"] = "imManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
@@ -35,22 +33,24 @@ class MessageManager {
|
||||
/// 发送消息
|
||||
/// [userID]接收消息的用户id
|
||||
/// [groupID]接收消息的组id
|
||||
Future<dynamic> sendMessage({
|
||||
Future<Message> sendMessage({
|
||||
required Message message,
|
||||
String? userID,
|
||||
String? groupID,
|
||||
OfflinePushInfo? offlinePushInfo,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'sendMessage',
|
||||
_buildParam({
|
||||
'message': message.toJson(),
|
||||
'userID': userID ?? '',
|
||||
'groupID': groupID ?? '',
|
||||
'offlinePushInfo': offlinePushInfo?.toJson(),
|
||||
'operationID': _checkOperationID(operationID),
|
||||
})) /*.then((value) => _toObj(value))*/;
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'sendMessage',
|
||||
_buildParam({
|
||||
'message': message.toJson(),
|
||||
'userID': userID ?? '',
|
||||
'groupID': groupID ?? '',
|
||||
'offlinePushInfo': offlinePushInfo?.toJson() ?? {},
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Find all history message
|
||||
/// 获取聊天记录
|
||||
@@ -71,9 +71,9 @@ class MessageManager {
|
||||
'groupID': groupID ?? '',
|
||||
'startClientMsgID': startMsg?.clientMsgID ?? '',
|
||||
'count': count ?? 10,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
.then((value) => Utils.toList(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Revoke the sent information
|
||||
/// 撤回消息
|
||||
@@ -85,7 +85,7 @@ class MessageManager {
|
||||
'revokeMessage',
|
||||
_buildParam(message.toJson()
|
||||
..addAll({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
})));
|
||||
|
||||
/// Delete message
|
||||
@@ -98,7 +98,7 @@ class MessageManager {
|
||||
'deleteMessageFromLocalStorage',
|
||||
_buildParam(message.toJson()
|
||||
..addAll({
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
})));
|
||||
|
||||
///
|
||||
@@ -119,7 +119,7 @@ class MessageManager {
|
||||
"message": message?.toJson(),
|
||||
"receiverID": receiverID,
|
||||
"senderID": senderID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Query the message according to the message id
|
||||
@@ -142,7 +142,7 @@ class MessageManager {
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
"userID": userID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Typing
|
||||
@@ -157,7 +157,7 @@ class MessageManager {
|
||||
_buildParam({
|
||||
"msgTip": msgTip,
|
||||
"userID": userID,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Create text message
|
||||
@@ -171,9 +171,9 @@ class MessageManager {
|
||||
'createTextMessage',
|
||||
_buildParam({
|
||||
'text': text,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create @ message
|
||||
/// 创建@消息
|
||||
@@ -188,10 +188,10 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'text': text,
|
||||
'atUserList': atUidList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create picture message
|
||||
/// 创建图片消息
|
||||
@@ -204,10 +204,10 @@ class MessageManager {
|
||||
'createImageMessage',
|
||||
_buildParam({
|
||||
'imagePath': imagePath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create picture message
|
||||
/// 创建图片消息
|
||||
@@ -220,10 +220,10 @@ class MessageManager {
|
||||
'createImageMessageFromFullPath',
|
||||
_buildParam({
|
||||
'imagePath': imagePath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create sound message
|
||||
/// 创建语音消息
|
||||
@@ -238,10 +238,10 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'soundPath': soundPath,
|
||||
"duration": duration,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create sound message
|
||||
/// 创建语音消息
|
||||
@@ -256,10 +256,10 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'soundPath': soundPath,
|
||||
"duration": duration,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create video message
|
||||
/// 创建视频消息
|
||||
@@ -278,9 +278,9 @@ class MessageManager {
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create video message
|
||||
/// 创建视频消息
|
||||
@@ -299,9 +299,9 @@ class MessageManager {
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create file message
|
||||
/// 创建文件消息
|
||||
@@ -316,9 +316,9 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'filePath': filePath,
|
||||
'fileName': fileName,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
}
|
||||
|
||||
/// Create file message
|
||||
@@ -334,9 +334,9 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'filePath': filePath,
|
||||
'fileName': fileName,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create merger message
|
||||
/// 创建合并消息
|
||||
@@ -353,9 +353,9 @@ class MessageManager {
|
||||
'messageList': messageList.map((e) => e.toJson()).toList(),
|
||||
'title': title,
|
||||
'summaryList': summaryList,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create forward message
|
||||
/// 创建转发消息
|
||||
@@ -368,9 +368,9 @@ class MessageManager {
|
||||
'createForwardMessage',
|
||||
_buildParam({
|
||||
'message': message.toJson(),
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
}
|
||||
|
||||
/// Create location message
|
||||
@@ -388,9 +388,9 @@ class MessageManager {
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'description': description,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create custom message
|
||||
/// 创建自定义消息
|
||||
@@ -407,9 +407,9 @@ class MessageManager {
|
||||
'data': data,
|
||||
'extension': extension,
|
||||
'description': description,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create quote message
|
||||
/// 创建引用消息
|
||||
@@ -424,9 +424,9 @@ class MessageManager {
|
||||
_buildParam({
|
||||
'quoteText': text,
|
||||
'quoteMessage': quoteMsg.toJson(),
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create card message
|
||||
/// 创建卡片消息
|
||||
@@ -439,9 +439,9 @@ class MessageManager {
|
||||
'createCardMessage',
|
||||
_buildParam({
|
||||
'cardMessage': data,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Clear all c2c history message
|
||||
/// 清空单聊消息记录
|
||||
@@ -453,7 +453,7 @@ class MessageManager {
|
||||
'clearC2CHistoryMessage',
|
||||
_buildParam({
|
||||
"userID": uid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Clear all group history
|
||||
@@ -466,31 +466,11 @@ class MessageManager {
|
||||
'clearGroupHistoryMessage',
|
||||
_buildParam({
|
||||
"groupID": gid,
|
||||
"operationID": _checkOperationID(operationID),
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
///
|
||||
// void forceSyncMsg() {
|
||||
// _channel.invokeMethod('forceSyncMsg', _buildParam({}));
|
||||
// }
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "messageManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<Message> _toList(String value) =>
|
||||
(_formatJson(value) as List).map((e) => Message.fromJson(e)).toList();
|
||||
|
||||
static Message _toObj(String value) => Message.fromJson(_formatJson(value));
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
|
||||
@@ -27,9 +25,9 @@ class UserManager {
|
||||
'getUsersInfo',
|
||||
_buildParam({
|
||||
'uidList': uidList,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => _toList(value, (v) => UserInfo.fromJson(v.cast())));
|
||||
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
|
||||
|
||||
/// Get the information of the currently logged in user
|
||||
/// 获取当前登录用户的信息
|
||||
@@ -40,9 +38,9 @@ class UserManager {
|
||||
.invokeMethod(
|
||||
'getSelfUserInfo',
|
||||
_buildParam({
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => UserInfo.fromJson(_formatJson(value)));
|
||||
.then((value) => Utils.toObj(value, (map) => UserInfo.fromJson(map)));
|
||||
|
||||
/// Modify current user info
|
||||
/// 修改当前登录用户资料
|
||||
@@ -52,7 +50,7 @@ class UserManager {
|
||||
int? gender,
|
||||
int? appMangerLevel,
|
||||
String? phoneNumber,
|
||||
String? birth,
|
||||
int? birth,
|
||||
String? email,
|
||||
String? ex,
|
||||
String? operationID,
|
||||
@@ -69,27 +67,11 @@ class UserManager {
|
||||
'birth': birth,
|
||||
'email': email,
|
||||
'ex': ex,
|
||||
'operationID': _checkOperationID(operationID),
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "userManager";
|
||||
return param;
|
||||
}
|
||||
|
||||
static List<T> _toList<T>(String? value, T f(Map map)) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <T>[];
|
||||
return (list as List).map((e) => f(e)).toList();
|
||||
}
|
||||
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ class ConversationInfo {
|
||||
|
||||
ConversationInfo.fromJson(Map<String, dynamic> json)
|
||||
: conversationID = json['conversationID'] {
|
||||
// conversationID = json['conversationID'];
|
||||
conversationType = json['conversationType'];
|
||||
userID = json['userID'];
|
||||
groupID = json['groupID'];
|
||||
@@ -46,8 +45,6 @@ class ConversationInfo {
|
||||
faceURL = json['faceURL'];
|
||||
recvMsgOpt = json['recvMsgOpt'];
|
||||
unreadCount = json['unreadCount'];
|
||||
// latestMsg = json['latestMsg'];
|
||||
// if (null != json['latestMsg']) {
|
||||
try {
|
||||
if (json['latestMsg'] is String) {
|
||||
latestMsg = Message.fromJson(jsonDecode(json['latestMsg']));
|
||||
@@ -55,9 +52,6 @@ class ConversationInfo {
|
||||
latestMsg = Message.fromJson(json['latestMsg']);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// }
|
||||
|
||||
latestMsgSendTime = json['latestMsgSendTime'];
|
||||
draftText = json['draftText'];
|
||||
draftTextTime = json['draftTextTime'];
|
||||
@@ -65,7 +59,7 @@ class ConversationInfo {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['conversationID'] = this.conversationID;
|
||||
data['conversationType'] = this.conversationType;
|
||||
data['userID'] = this.userID;
|
||||
@@ -82,10 +76,9 @@ class ConversationInfo {
|
||||
return data;
|
||||
}
|
||||
|
||||
bool get isSingleChat => conversationType == ConversationType.single_chat;
|
||||
|
||||
bool get isGroupChat => conversationType == ConversationType.group_chat;
|
||||
bool get isSingleChat => conversationType == ConversationType.single;
|
||||
|
||||
bool get isGroupChat => conversationType == ConversationType.group;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
|
||||
@@ -43,7 +43,7 @@ class GroupInfo {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['groupName'] = this.groupName;
|
||||
data['notification'] = this.notification;
|
||||
@@ -96,7 +96,7 @@ class GroupMembersInfo {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['groupID'] = this.groupID;
|
||||
data['userID'] = this.userID;
|
||||
data['roleLevel'] = this.roleLevel;
|
||||
@@ -125,7 +125,7 @@ class GroupMemberRole {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['userID'] = this.userID;
|
||||
data['roleLevel'] = this.roleLevel;
|
||||
return data;
|
||||
@@ -148,7 +148,10 @@ class GroupApplicationInfo {
|
||||
String? nickname;
|
||||
String? userFaceURL;
|
||||
int? gender;
|
||||
int? handleResult; //REFUSE = -1, AGREE = 1
|
||||
|
||||
/// REFUSE = -1, AGREE = 1
|
||||
/// -1:拒绝,1:同意
|
||||
int? handleResult;
|
||||
String? reqMsg;
|
||||
String? handledMsg;
|
||||
int? reqTime;
|
||||
@@ -246,59 +249,9 @@ class GroupInviteResult {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['userID'] = this.userID;
|
||||
data['result'] = this.result;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// class GroupMembersList {
|
||||
// int? nextSeq;
|
||||
// List<GroupMembersInfo>? data;
|
||||
//
|
||||
// GroupMembersList({this.nextSeq, this.data});
|
||||
//
|
||||
// GroupMembersList.fromJson(Map<String, dynamic> json) {
|
||||
// nextSeq = json['nextSeq'];
|
||||
// if (json['data'] is List) {
|
||||
// data = (json['data'] as List)
|
||||
// .map((e) => GroupMembersInfo.fromJson(e))
|
||||
// .toList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['nextSeq'] = this.nextSeq;
|
||||
// if (this.data != null) {
|
||||
// data['data'] = this.data!.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class GroupApplicationList {
|
||||
// int? count;
|
||||
// List<GroupApplicationInfo>? user;
|
||||
//
|
||||
// GroupApplicationList({this.count, this.user});
|
||||
//
|
||||
// GroupApplicationList.fromJson(Map<String, dynamic> json) {
|
||||
// count = json['count'];
|
||||
// if (json['user'] is List) {
|
||||
// user = (json['user'] as List)
|
||||
// .map((e) => GroupApplicationInfo.fromJson(e))
|
||||
// .toList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['count'] = this.count;
|
||||
// if (this.user != null) {
|
||||
// data['user'] = this.user!.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -71,8 +71,7 @@ class Message {
|
||||
this.notificationElem,
|
||||
});
|
||||
|
||||
Message.fromJson(
|
||||
Map<String, dynamic> json) /* : clientMsgID = json['clientMsgID']*/ {
|
||||
Message.fromJson(Map<String, dynamic> json) {
|
||||
clientMsgID = json['clientMsgID'];
|
||||
serverMsgID = json['serverMsgID'];
|
||||
createTime = json['createTime'];
|
||||
@@ -127,7 +126,7 @@ class Message {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['clientMsgID'] = this.clientMsgID;
|
||||
data['serverMsgID'] = this.serverMsgID;
|
||||
data['createTime'] = this.createTime;
|
||||
@@ -171,6 +170,41 @@ class Message {
|
||||
|
||||
@override
|
||||
int get hashCode => clientMsgID.hashCode;
|
||||
|
||||
void update(Message message) {
|
||||
if (clientMsgID != message.clientMsgID) return;
|
||||
// clientMsgID = message.clientMsgID;
|
||||
serverMsgID = message.serverMsgID;
|
||||
createTime = message.createTime;
|
||||
sendTime = message.sendTime;
|
||||
sendID = message.sendID;
|
||||
recvID = message.recvID;
|
||||
msgFrom = message.msgFrom;
|
||||
contentType = message.contentType;
|
||||
platformID = message.platformID;
|
||||
senderNickname = message.senderNickname;
|
||||
senderFaceUrl = message.senderFaceUrl;
|
||||
groupID = message.groupID;
|
||||
content = message.content;
|
||||
seq = message.seq;
|
||||
isRead = message.isRead;
|
||||
status = message.status;
|
||||
offlinePush = message.offlinePush;
|
||||
attachedInfo = message.attachedInfo;
|
||||
ex = message.ex;
|
||||
ext = message.ext;
|
||||
sessionType = message.sessionType;
|
||||
pictureElem = message.pictureElem;
|
||||
soundElem = message.soundElem;
|
||||
videoElem = message.videoElem;
|
||||
fileElem = message.fileElem;
|
||||
atElem = message.atElem;
|
||||
locationElem = message.locationElem;
|
||||
customElem = message.customElem;
|
||||
quoteElem = message.quoteElem;
|
||||
mergeElem = message.mergeElem;
|
||||
notificationElem = message.notificationElem;
|
||||
}
|
||||
}
|
||||
|
||||
class PictureElem {
|
||||
@@ -199,7 +233,7 @@ class PictureElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['sourcePath'] = this.sourcePath;
|
||||
if (this.sourcePicture != null) {
|
||||
data['sourcePicture'] = this.sourcePicture?.toJson();
|
||||
@@ -235,7 +269,7 @@ class PictureInfo {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['uuid'] = this.uuid;
|
||||
data['type'] = this.type;
|
||||
data['size'] = this.size;
|
||||
@@ -269,7 +303,7 @@ class SoundElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['uuid'] = this.uuid;
|
||||
data['soundPath'] = this.soundPath;
|
||||
data['sourceUrl'] = this.sourceUrl;
|
||||
@@ -323,7 +357,7 @@ class VideoElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['videoPath'] = this.videoPath;
|
||||
data['videoUUID'] = this.videoUUID;
|
||||
data['videoUrl'] = this.videoUrl;
|
||||
@@ -359,7 +393,7 @@ class FileElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['filePath'] = this.filePath;
|
||||
data['uuid'] = this.uuid;
|
||||
data['sourceUrl'] = this.sourceUrl;
|
||||
@@ -385,7 +419,7 @@ class AtElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['text'] = this.text;
|
||||
data['atUserList'] = this.atUserList;
|
||||
data['isAtSelf'] = this.isAtSelf;
|
||||
@@ -416,7 +450,7 @@ class LocationElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['description'] = this.description;
|
||||
data['longitude'] = this.longitude;
|
||||
data['latitude'] = this.latitude;
|
||||
@@ -438,7 +472,7 @@ class CustomElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['data'] = this.data;
|
||||
data['extension'] = this.extension;
|
||||
data['description'] = this.description;
|
||||
@@ -460,7 +494,7 @@ class QuoteElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['text'] = this.text;
|
||||
data['quoteMessage'] = this.quoteMessage?.toJson();
|
||||
return data;
|
||||
@@ -487,7 +521,7 @@ class MergeElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['title'] = this.title;
|
||||
data['abstractList'] = this.abstractList;
|
||||
data['multiMessage'] = this.multiMessage?.map((e) => e.toJson()).toList();
|
||||
@@ -507,14 +541,14 @@ class NotificationElem {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['detail'] = this.detail;
|
||||
data['defaultTips'] = this.defaultTips;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class HaveReadInfo {
|
||||
class ReadReceiptInfo {
|
||||
String? uid;
|
||||
List<String>? msgIDList;
|
||||
int? readTime;
|
||||
@@ -522,7 +556,7 @@ class HaveReadInfo {
|
||||
int? contentType;
|
||||
int? sessionType;
|
||||
|
||||
HaveReadInfo(
|
||||
ReadReceiptInfo(
|
||||
{this.uid,
|
||||
this.msgIDList,
|
||||
this.readTime,
|
||||
@@ -530,7 +564,7 @@ class HaveReadInfo {
|
||||
this.contentType,
|
||||
this.sessionType});
|
||||
|
||||
HaveReadInfo.fromJson(Map<String, dynamic> json) {
|
||||
ReadReceiptInfo.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
if (json['msgIDList'] is List) {
|
||||
msgIDList = (json['msgIDList'] as List).map((e) => '$e').toList();
|
||||
@@ -542,7 +576,7 @@ class HaveReadInfo {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['uid'] = this.uid;
|
||||
data['msgIDList'] = this.msgIDList;
|
||||
data['readTime'] = this.readTime;
|
||||
@@ -572,7 +606,7 @@ class OfflinePushInfo {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
final data = Map<String, dynamic>();
|
||||
data['title'] = this.title;
|
||||
data['desc'] = this.desc;
|
||||
data['ex'] = this.ex;
|
||||
|
||||
27
lib/src/utils.dart
Normal file
27
lib/src/utils.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class Utils {
|
||||
static List<T> toList<T>(String? value, T f(Map<String, dynamic> map)) {
|
||||
var list = _formatJson(value);
|
||||
if (null == list) return <T>[];
|
||||
return (list as List).map((e) => f(e)).toList();
|
||||
}
|
||||
|
||||
static T toObj<T>(String value, T f(Map<String, dynamic> map)) =>
|
||||
f(_formatJson(value));
|
||||
|
||||
static List<dynamic> toListMap(String? value) => _formatJson(value) ?? [];
|
||||
|
||||
static dynamic _formatJson(String? value) {
|
||||
if (null == value) return null;
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
static String checkOperationID(String? obj) {
|
||||
return obj ?? DateTime.now().millisecondsSinceEpoch.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user