main
hrxiang 4 years ago
parent 470bbb960e
commit 1e87794ec5
  1. 10
      CHANGELOG.md
  2. 7
      lib/src/enum/listener_type.dart
  3. 5
      lib/src/listener/advanced_msg_listener.dart
  4. 14
      lib/src/listener/init_sdk_listener.dart
  5. 37
      lib/src/manager/im_conversation_manager.dart
  6. 42
      lib/src/manager/im_friendship_manager.dart
  7. 36
      lib/src/manager/im_group_manager.dart
  8. 30
      lib/src/manager/im_manager.dart
  9. 57
      lib/src/manager/im_message_manager.dart

@ -1,3 +1,5 @@
## 0.0.8+1
## 0.0.8
Upgrade sdk to 0.0.14 </br>
Sending a message adds a retry mechanism
@ -7,7 +9,7 @@ Sending a message adds a retry mechanism
2. Modify the type of conversation manager input parameter sessionType to int
## 0.0.6
fix bug
Fix bug
## 0.0.5
Upgrade sdk </br>
@ -18,8 +20,8 @@ fix message error bug
Replace the input parameters of the createCustomMessage method from Uint8List to Map
## 0.0.3
upgrade sdk </br>
fix bug </br>
Upgrade sdk </br>
Fix bug </br>
## 0.0.2
1. Move the markSingleMessageHasRead, markGroupMessageHasRead and getTotalUnreadMsgCount methods from the MessageManager class to the ConversationManager class. </br>
@ -28,4 +30,4 @@ fix bug </br>
## 0.0.1
initial release.
Initial release.

@ -1,17 +1,10 @@
class ListenerType {
static const simpleMsgListener = 'simpleMsgListener';
static const initSDKListener = 'initSDKListener';
static const groupListener = 'groupListener';
static const advancedMsgListener = 'advancedMsgListener';
static const conversationListener = 'conversationListener';
static const friendListener = 'friendListener';
static const signalingListener = 'signalingListener';
static const msgSendProgressListener = "msgSendProgressListener";
}

@ -2,14 +2,17 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class AdvancedMsgListener {
/// listener uniquely identifies
/// Uniquely identifies
final String id;
AdvancedMsgListener() : id = "id_${DateTime.now().microsecondsSinceEpoch}";
/// Receive new message
void recvNewMessage(Message msg);
/// Message read receipt
void recvC2CReadReceipt(List<HaveReadInfo> list);
/// A friend withdrew a message
void recvMessageRevoked(String msgId);
}

@ -1,21 +1,23 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class InitSDKListener {
/// SDK
/// SDK is connecting to the server
void connecting();
/// SDK
/// SDK has successfully connected to the server
void connectSuccess();
/// SDK
/// SDK failed to connect to the server
void connectFailed(int? code, String? errorMsg);
/// 线 UI IMManager login()
/// The current user is kicked offline.
/// At this time, the UI can prompt the user and call IMManager's login() function to log in again.
void kickedOffline();
/// 线 userSig IMManager login()
/// Ticket expired when online.
/// At this time, you need to generate a new userSig and call IMManager's login() function to log in again
void userSigExpired();
///
/// The information of the logged-in user has been updated
void selfInfoUpdated(UserInfo info);
}

@ -11,22 +11,20 @@ class ConversationManager {
ConversationManager(this._channel);
/// listener[ConversationListener]Observe conversation changes
///
/// Observe conversation changes
Future setConversationListener(ConversationListener listener) {
this.conversationListener = listener;
return _channel.invokeMethod('setConversationListener', _buildParam({}));
}
/// get all conversations
///
/// Get all conversations
Future<List<ConversationInfo>> getAllConversationList() => _channel
.invokeMethod('getAllConversationList', _buildParam({}))
.then((value) => _toList(value));
/// 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
///
/// Get a single conversation info
/// [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 int sessionType,
@ -40,8 +38,7 @@ class ConversationManager {
}))
.then((value) => _toObj(value));
/// get conversation list by id list
///
/// Get conversation list by id list
Future<List<ConversationInfo>> getMultipleConversation({
required List<String> conversationIDList,
}) =>
@ -53,8 +50,7 @@ class ConversationManager {
}))
.then((value) => _toList(value));
/// delete conversation by id
///
/// Delete conversation by id
Future deleteConversation({
required String conversationID,
}) =>
@ -66,8 +62,7 @@ class ConversationManager {
}))
.then((value) => _printValue(value));
/// set draft
///
/// Set draft
Future setConversationDraft({
required String conversationID,
required String draftText,
@ -81,8 +76,7 @@ class ConversationManager {
}))
.then((value) => _printValue(value));
/// pinned conversation
///
/// Pinned conversation
Future pinConversation({
required String conversationID,
required bool isPinned,
@ -96,27 +90,26 @@ class ConversationManager {
}))
.then((value) => _printValue(value));
///
/// @params userID: receiver's userID
/// Mark single chat messages as read
Future<dynamic> markSingleMessageHasRead({required String userID}) {
return _channel.invokeMethod(
'markSingleMessageHasRead', _buildParam({'userID': userID}));
}
///
/// Mark group chat messages as read
Future<dynamic> markGroupMessageHasRead({required String groupID}) {
return _channel.invokeMethod(
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
}
///
/// Get the total number of unread messages
Future<dynamic> getTotalUnreadMsgCount() {
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
}
/// 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
///
/// Query conversation id
/// [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<dynamic> getConversationID({
required String sourceID,
required int sessionType,

@ -9,52 +9,47 @@ class FriendshipManager {
FriendshipManager(this._channel);
/// listener[FriendshipListener]
///
/// Set up a friend relationship listener
Future setFriendshipListener(FriendshipListener listener) {
this.friendshipListener = listener;
return _channel.invokeMethod('setFriendListener', _buildParam({}));
}
/// get friend info by userid
///
/// Get friend info by user id
Future<List<UserInfo>> getFriendsInfo({required List<String> uidList}) {
return _channel
.invokeMethod('getFriendsInfo', _buildParam({"uidList": uidList}))
.then((value) => _toList(value));
}
/// send an friend application
///
/// 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
/// Get all friend application, sent to you by others
Future<List<UserInfo>> getFriendApplicationList() {
return _channel
.invokeMethod('getFriendApplicationList', _buildParam({}))
.then((value) => _toList(value));
}
/// find all friends
///
/// Find all friends including those who have been added to the blacklist
Future<List<UserInfo>> getFriendList() {
return _channel
.invokeMethod('getFriendList', _buildParam({}))
.then((value) => _toList(value));
}
/// Find all friends including those who have been added to the blacklist
Future<List<dynamic>> getFriendListMap() {
return _channel
.invokeMethod('getFriendList', _buildParam({}))
.then((value) => _toListMap(value));
}
/// modify friend information, only [comment] can be modified
///
/// Modify friend information, only [comment] can be modified
Future<dynamic> setFriendInfo(
{required String uid, required String comment}) {
return _channel.invokeMethod(
@ -65,63 +60,54 @@ class FriendshipManager {
}));
}
/// add to blacklist
///
/// Add friends to blacklist
Future<dynamic> addToBlackList({required String uid}) {
return _channel.invokeMethod('addToBlackList', _buildParam({"uid": uid}));
}
/// find all blacklist
///
/// Find all blacklist
Future<List<UserInfo>> getBlackList() {
return _channel
.invokeMethod('getBlackList', _buildParam({}))
.then((value) => _toList(value));
}
/// remove from blacklist
///
/// Remove from blacklist
Future<dynamic> deleteFromBlackList({required String uid}) {
return _channel.invokeMethod(
'deleteFromBlackList', _buildParam({"uid": uid}));
}
/// determine if there is a friendship by userId
///
/// 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
///
/// Dissolve friendship from friend list
Future<dynamic> deleteFromFriendList({required String uid}) {
return _channel.invokeMethod(
'deleteFromFriendList', _buildParam({"uid": uid}));
}
/// accept application of be friend
///
/// Accept application of be friend
Future<dynamic> acceptFriendApplication({required String uid}) {
return _channel.invokeMethod(
'acceptFriendApplication', _buildParam({"uid": uid}));
}
/// refuse application of be friend
///
/// 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({}));

@ -10,14 +10,13 @@ class GroupManager {
GroupManager(this._channel);
/// listener[GroupListener]
/// Set up group relationship monitoring
Future setGroupListener(GroupListener listener) {
this.groupListener = listener;
return _channel.invokeMethod('setGroupListener', _buildParam({}));
}
/// invite friends into the group
///
/// Invite friends into the group
Future<List<GroupInviteResult>> inviteUserToGroup({
required String groupId,
required List<String> uidList,
@ -36,7 +35,7 @@ class GroupManager {
.toList());
}
/// remove member from group
/// Remove member from group
Future<List<GroupInviteResult>> kickGroupMember({
required String groupId,
required List<String> uidList,
@ -55,7 +54,7 @@ class GroupManager {
.toList());
}
/// get group member's info
/// Get group member's info
Future<List<GroupMembersInfo>> getGroupMembersInfo({
required String groupId,
required List<String> uidList,
@ -72,8 +71,9 @@ class GroupManager {
.toList());
}
/// filter 0: all user, 1: group owner, 2: administrator
/// begin index, pull and fill 0 for the first time
/// Get the list of group members
/// [filter] 0: all user, 1: group owner, 2: administrator
/// [next] begin index, pull and fill 0 for the first time
Future<GroupMembersList> getGroupMemberList({
required String groupId,
int filter = 0,
@ -90,8 +90,7 @@ class GroupManager {
.then((value) => GroupMembersList.fromJson(_formatJson(value)));
}
// filter 0: all user, 1: group owner, 2: administrator
/// begin index, pull and fill 0 for the first time
/// Get the list of group members
Future<dynamic> getGroupMemberListMap({
required String groupId,
int filter = 0,
@ -108,7 +107,7 @@ class GroupManager {
.then((value) => _formatJson(value));
}
/// find all groups you have joined
/// Find all groups you have joined
Future<List<GroupInfo>> getJoinedGroupList() {
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then(
(value) => (_formatJson(value) as List)
@ -116,21 +115,20 @@ class GroupManager {
.toList());
}
/// find all groups you have joined
/// Find all groups you have joined
Future<List<dynamic>> getJoinedGroupListMap() {
return _channel
.invokeMethod('getJoinedGroupList', _buildParam({}))
.then((value) => _formatJson(value));
}
/// check
/// Check if you are a member of the group
Future<bool> isJoinedGroup({required String gid}) {
return getJoinedGroupList()
.then((list) => list.where((e) => e.groupID == gid).length > 0);
}
/// create a group
/// @params list[List<GroupMemberRole>]: Group members you invited
/// Create a group
Future<dynamic> createGroup({
String? groupName,
String? notification,
@ -173,7 +171,7 @@ class GroupManager {
}));
}
/// find group information by group id
/// Find group information by group id
Future<List<GroupInfo>> getGroupsInfo({
required List<String> gidList,
}) {
@ -198,7 +196,7 @@ class GroupManager {
}));
}
///
/// Leave group
Future<dynamic> quitGroup({
required String gid,
}) {
@ -222,14 +220,14 @@ class GroupManager {
}));
}
///
/// Get the list of applications
Future<GroupApplicationList> getGroupApplicationList() {
return _channel
.invokeMethod('getGroupApplicationList', _buildParam({}))
.then((value) => GroupApplicationList.fromJson(_formatJson(value)));
}
///
/// Accept group application
Future<dynamic> acceptGroupApplication({
required GroupApplicationInfo info,
required String reason,
@ -242,7 +240,7 @@ class GroupManager {
}));
}
///
/// Refuse group application
Future<dynamic> refuseGroupApplication({
required GroupApplicationInfo info,
required String reason,

@ -265,12 +265,12 @@ class IMManager {
});
}
/// init sdk
/// Initialize SDK
///
/// @params platform[IMPlatform]
/// @params ipApi: api server ip address
/// @params ipWs: websocket ip address
/// @params dbPath: data storage directory
/// [platform] Refer to [IMPlatform]
/// [ipApi] Api server ip address
/// [ipWs] WebSocket ip address
/// [dbPath] Data storage directory
Future<dynamic> initSDK({
required int platform,
required String ipApi,
@ -290,13 +290,10 @@ class IMManager {
"dbDir": dbPath
},
))
.then((value) {
isInitialized = true;
return value;
});
.then((value) => isInitialized = true);
}
///
@deprecated
Future<dynamic> unInitSDK() {
return _channel.invokeMethod('unInitSDK', _buildParam({})).then((value) {
isInitialized = false;
@ -304,8 +301,7 @@ class IMManager {
});
}
/// login sdk
///
/// Login sdk
Future<UserInfo> login({required String uid, required String token}) async {
this.uid = uid;
await _channel.invokeMethod(
@ -316,7 +312,7 @@ class IMManager {
return uInfo;
}
///
/// Logout sdk
Future<dynamic> logout() {
return _channel.invokeMethod('logout', _buildParam({}));
}
@ -326,18 +322,18 @@ class IMManager {
return _channel.invokeMethod<int>('getLoginStatus', _buildParam({}));
}
///
/// Current user id
Future<String?> getLoginUid() {
return Future.value(uid);
// return _channel.invokeMethod<String>('getLoginUid', _buildParam({}));
}
///
/// Current user info
Future<UserInfo> getLoginUserInfo() {
return Future.value(uInfo);
}
///
/// Modify current user info
Future<String?> setSelfInfo(
{required String uid,
String? name,
@ -362,7 +358,7 @@ class IMManager {
// .then((value) => UserInfo.fromJson(value));
}
///
/// Query user information
Future<List<UserInfo>> getUsersInfo(List<String> uidList) {
return _channel
.invokeMethod('getUsersInfo', _buildParam({'uidList': uidList}))

@ -10,7 +10,7 @@ class MessageManager {
MessageManager(this._channel);
///
/// Add a message listener
Future addAdvancedMsgListener(AdvancedMsgListener listener) {
advancedMsgListeners.add(listener);
return _channel.invokeMethod(
@ -20,7 +20,7 @@ class MessageManager {
}));
}
///
/// Remove a message listener
Future removeAdvancedMsgListener(AdvancedMsgListener listener) {
advancedMsgListeners.remove(listener);
return _channel.invokeMethod(
@ -30,13 +30,13 @@ class MessageManager {
}));
}
///
/// Set up message sending progress monitoring
void setMsgSendProgressListener(MsgSendProgressListener listener) {
msgSendProgressListener = listener;
}
/// send a message to user or to group
/// userID: receiver's user ID
/// Send a message to user or to group
/// [userID] receiver's user ID
Future<dynamic> sendMessage({
required Message message,
String? userID,
@ -54,8 +54,7 @@ class MessageManager {
/*.then((value) => _toObj(value))*/;
}
/// find all history message
/// userID: the user id of the chat partner
/// Find all history message
Future<List<Message>> getHistoryMessageList({
String? userID,
String? groupID,
@ -74,13 +73,13 @@ class MessageManager {
.then((value) => _toList(value));
}
/// revoke the sent information
/// Revoke the sent information
Future revokeMessage({required Message message}) {
return _channel.invokeMethod(
'revokeMessage', _buildParam(message.toJson()));
}
/// delete message
/// Delete message
Future deleteMessageFromLocalStorage({required Message message}) {
return _channel.invokeMethod(
'deleteMessageFromLocalStorage', _buildParam(message.toJson()));
@ -94,8 +93,6 @@ class MessageManager {
}
///
/// @params userID: receiver's user ID
/// @params sender: current user ID
Future insertSingleMessageToLocalStorage({
String? receiver,
String? sender,
@ -110,7 +107,7 @@ class MessageManager {
}));
}
///
/// Query the message according to the message id
Future findMessages({required List<String> messageIDList}) {
return _channel.invokeMethod(
'findMessages',
@ -119,8 +116,7 @@ class MessageManager {
}));
}
///
/// @params userID: receiver's user ID
/// Mark c2c message as read
Future markC2CMessageAsRead({
required String userID,
required List<String> messageIDList,
@ -133,9 +129,7 @@ class MessageManager {
}));
}
///
/// @params userID: receiver's user ID
/// @params status: default no
/// Typing
Future typingStatusUpdate({
required String userID,
bool typing = false,
@ -148,14 +142,14 @@ class MessageManager {
}));
}
///
/// Create text message
Future<Message> createTextMessage({required String text}) {
return _channel
.invokeMethod('createTextMessage', _buildParam({'text': text}))
.then((value) => _toObj(value));
}
///
/// Create @ message
Future<Message> createTextAtMessage({
required String text,
required List<String> atUidList,
@ -171,7 +165,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create picture message
Future<Message> createImageMessage({required String imagePath}) {
return _channel
.invokeMethod(
@ -181,7 +175,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create picture message
Future<Message> createImageMessageFromFullPath({required String imagePath}) {
return _channel
.invokeMethod(
@ -191,7 +185,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create sound message
Future<Message> createSoundMessage({
required String soundPath,
required int duration,
@ -204,7 +198,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create sound message
Future<Message> createSoundMessageFromFullPath({
required String soundPath,
required int duration,
@ -217,7 +211,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create video message
Future<Message> createVideoMessage({
required String videoPath,
required String videoType,
@ -236,7 +230,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create video message
Future<Message> createVideoMessageFromFullPath({
required String videoPath,
required String videoType,
@ -255,7 +249,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create file message
Future<Message> createFileMessage({
required String filePath,
required String fileName,
@ -270,7 +264,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create merger message
Future<Message> createMergerMessage({
required List<Message> messageList,
required String title,
@ -287,7 +281,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create forward message
Future<Message> createForwardMessage({required Message message}) {
return _channel
.invokeMethod(
@ -298,7 +292,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create location message
Future<Message> createLocationMessage({
required double latitude,
required double longitude,
@ -315,7 +309,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create custom message
Future<Message> createCustomMessage({
required String data,
required String extension,
@ -332,7 +326,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
///
/// Create quote message
Future<Message> createQuoteMessage({
required String text,
required Message quoteMsg,
@ -347,6 +341,7 @@ class MessageManager {
.then((value) => _toObj(value));
}
/// Create card message
Future<Message> createCardMessage({
required Map<String, dynamic> data,
}) {

Loading…
Cancel
Save