init
This commit is contained in:
parent
599decfd38
commit
3bcc338945
@ -7,7 +7,7 @@ buildscript {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||
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://47.112.160.66:8081/repository/maven-releases'}
|
||||
maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
|
||||
google()
|
||||
mavenCentral()
|
||||
@ -24,7 +24,7 @@ rootProject.allprojects {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||
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://47.112.160.66: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:0.0.7@aar'
|
||||
// implementation 'io.openim:client-sdk:1.0.0@aar'//graoupId:artifactId:version@aar
|
||||
}
|
@ -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 = 112;
|
||||
|
||||
///
|
||||
static const accept_friend = 201;
|
||||
|
@ -11,5 +11,5 @@ class AdvancedMsgListener {
|
||||
|
||||
void onRecvC2CReadReceipt(Message msg) {}
|
||||
|
||||
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({}));
|
||||
}
|
||||
|
@ -138,10 +138,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']));
|
||||
|
||||
switch (type) {
|
||||
case 'onRecvNewMessage':
|
||||
var msg = Message.fromJson(
|
||||
_formatJson(call.arguments['data']['message']));
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.onRecvNewMessage(msg);
|
||||
@ -149,16 +150,17 @@ class IMManager {
|
||||
}
|
||||
break;
|
||||
case 'onRecvMessageRevoked':
|
||||
var msgId = call.arguments['data']['message'];
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.onRecvMessageRevoked(msg);
|
||||
listener.onRecvMessageRevoked(msgId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'onRecvC2CReadReceipt':
|
||||
for (var listener in messageManager.advancedMsgListeners) {
|
||||
if (listener.id == id) {
|
||||
listener.onRecvC2CReadReceipt(msg);
|
||||
listener.onRecvC2CReadReceipt(Message());
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -260,6 +262,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 +284,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 +299,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
|
||||
///
|
||||
Future<dynamic> sendMessage({
|
||||
required Message message,
|
||||
String? userID,
|
||||
@ -51,6 +54,7 @@ class MessageManager {
|
||||
/*.then((value) => _toObj(value))*/;
|
||||
}
|
||||
|
||||
/// find all history message
|
||||
Future<List<Message>> getHistoryMessageList({
|
||||
String? userID,
|
||||
String? groupID,
|
||||
@ -69,21 +73,26 @@ 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()}));
|
||||
}
|
||||
|
||||
///
|
||||
Future insertSingleMessageToLocalStorage({
|
||||
String? userID,
|
||||
Message? message,
|
||||
@ -98,6 +107,7 @@ class MessageManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
Future findMessages({required List<String> messageIDList}) {
|
||||
return _channel.invokeMethod(
|
||||
'findMessages',
|
||||
@ -106,22 +116,26 @@ class MessageManager {
|
||||
}));
|
||||
}
|
||||
|
||||
///
|
||||
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}));
|
||||
}
|
||||
|
||||
///
|
||||
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 +151,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createImageMessage({required String imagePath}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
@ -146,6 +161,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createSoundMessage({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
@ -158,6 +174,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createVideoMessage({
|
||||
required String videoPath,
|
||||
required String videoType,
|
||||
@ -176,6 +193,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createFileMessage({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
@ -190,6 +208,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createMergerMessage({
|
||||
required List<Message> messageList,
|
||||
required String title,
|
||||
@ -206,6 +225,7 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createForwardMessage({required List<Message> messageList}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
@ -216,131 +236,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,
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user