This commit is contained in:
hrxiang
2021-07-14 16:19:21 +08:00
parent c15773e28c
commit 9ac48d065a
13 changed files with 232 additions and 77 deletions

View File

@@ -3,6 +3,7 @@ library flutter_openim_sdk;
export 'src/enum/conversation_type.dart';
export 'src/enum/group_role.dart';
export 'src/enum/listener_type.dart';
export 'src/enum/message_status.dart';
export 'src/enum/message_type.dart';
export 'src/listener/advanced_msg_listener.dart';
export 'src/listener/conversation_listener.dart';

View File

@@ -0,0 +1,6 @@
class MessageStatus{
static const sending = 1;
static const succeeded = 2;
static const failed = 3;
static const deleted = 4;
}

View File

@@ -1,20 +1,32 @@
class MessageType {
///
static const text = 101;
///
static const picture = 102;
///
static const voice = 103;
///
static const video = 104;
static const file = 105;
static const at_text = 106;
static const merger = 107;
///
static const file = 105;
static const accept_friend = 201;
static const add_friend = 202;
static const refuse_friend_application = 203;
static const set_self_info = 204;
static const revoke_message = 205;
static const c2c_message_as_read = 206;
static const kick_online = 303;
///
static const transfer_group_owner = 501;
static const create_group = 502;
// static const create_group = 503;
static const join_group = 504;
static const quit_group = 505;
static const set_group_info = 506;
static const accept_group_application = 507;
static const refuse_group_application = 508;
static const kick_group_member = 509;
static const invited_user_to_group = 510;
}

View File

@@ -46,7 +46,7 @@ class GroupManager {
'reason': reason,
'uidList': uidList,
}))
.then((value) => _formatJson(value)
.then((value) => (_formatJson(value) as List)
.map((e) => GroupInviteResult.fromJson(e))
.toList());
}
@@ -71,8 +71,8 @@ class GroupManager {
///begin index, pull and fill 0 for the first time
Future<GroupMembersList> getGroupMemberList({
required String groupId,
required int filter,
required int next,
int filter = 0,
int next = 0,
}) {
return _channel
.invokeMethod(
@@ -195,6 +195,22 @@ class GroupManager {
}));
}
void forceSyncApplyGroupRequest() {
_channel.invokeMethod('forceSyncApplyGroupRequest', _buildParam({}));
}
void forceSyncGroupRequest() {
_channel.invokeMethod('forceSyncGroupRequest', _buildParam({}));
}
void forceSyncJoinedGroup() {
_channel.invokeMethod('forceSyncJoinedGroup', _buildParam({}));
}
void forceSyncJoinedGroupMember() {
_channel.invokeMethod('forceSyncJoinedGroupMember', _buildParam({}));
}
static Map _buildParam(Map param) {
param["ManagerName"] = "groupManager";
return param;

View File

@@ -12,7 +12,9 @@ class IMManager {
late OfflinePushManager offlinePushManager;
late SignalingManager signalingManager;
late InitSDKListener _initSDKListener;
late String logUid;
late String uid;
// late UserInfo userInfo;
IMManager(this._channel) {
conversationManager = ConversationManager(_channel);
@@ -32,8 +34,8 @@ class IMManager {
dynamic data = call.arguments['data'];
switch (type) {
case 'onSelfInfoUpdated':
var u = UserInfo.fromJson(_formatJson(data));
_initSDKListener.onSelfInfoUpdated(u);
_initSDKListener
.onSelfInfoUpdated(UserInfo.fromJson(_formatJson(data)));
break;
case 'onConnectFailed':
int? errCode = call.arguments['errCode'];
@@ -279,8 +281,8 @@ class IMManager {
return _channel.invokeMethod('unInitSDK', _buildParam({}));
}
Future<dynamic> login({required String uid, required String token}) {
this.logUid = uid;
Future<dynamic> login({required String uid, required String token}) async {
this.uid = uid;
return _channel.invokeMethod(
'login',
_buildParam({'uid': uid, 'token': token}),
@@ -296,7 +298,12 @@ class IMManager {
}
Future<String?> getLoginUid() {
return _channel.invokeMethod<String>('getLoginUid', _buildParam({}));
return Future.value(uid);
// return _channel.invokeMethod<String>('getLoginUid', _buildParam({}));
}
Future<UserInfo> getLoginUserInfo() {
return getUsersInfo([uid]).then((list) => list[0]);
}
Future<String?> setSelfInfo(UserInfo info) {
@@ -314,6 +321,10 @@ class IMManager {
return _channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
}
Future<dynamic> forceReConn() {
return _channel.invokeMethod('forceReConn', _buildParam({}));
}
static Map _buildParam(Map param) {
param["ManagerName"] = "imManager";
return param;

View File

@@ -202,6 +202,10 @@ class MessageManager {
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
}
void forceSyncMsg() {
_channel.invokeMethod('forceSyncMsg', _buildParam({}));
}
static Map _buildParam(Map param) {
param["ManagerName"] = "messageManager";
return param;

View File

@@ -75,14 +75,17 @@ class GroupMembersInfo {
int? joinTime;
String? nickName;
String? faceUrl;
dynamic ext;
GroupMembersInfo(
{this.groupID,
this.userId,
this.role,
this.joinTime,
this.nickName,
this.faceUrl});
GroupMembersInfo({
this.groupID,
this.userId,
this.role,
this.joinTime,
this.nickName,
this.faceUrl,
this.ext,
});
GroupMembersInfo.fromJson(Map<String, dynamic> json) {
groupID = json['groupID'];
@@ -91,6 +94,7 @@ class GroupMembersInfo {
joinTime = json['joinTime'];
nickName = json['nickName'];
faceUrl = json['faceUrl'];
ext = json['ext'];
}
Map<String, dynamic> toJson() {
@@ -101,6 +105,7 @@ class GroupMembersInfo {
data['joinTime'] = this.joinTime;
data['nickName'] = this.nickName;
data['faceUrl'] = this.faceUrl;
data['ext'] = this.ext;
return data;
}
}

View File

@@ -23,32 +23,35 @@ class Message {
SoundElem? soundElem;
VideoElem? videoElem;
FileElem? fileElem;
AtElem? atElem;
Message(
{this.clientMsgID,
this.serverMsgID,
this.createTime,
this.sendTime,
this.sendID,
this.recvID,
this.msgFrom,
this.contentType,
this.platformID,
this.forceList,
this.senderNickName,
this.senderFaceUrl,
this.groupID,
this.content,
this.seq,
this.isRead,
this.status,
this.remark,
this.ext,
this.sessionType,
this.pictureElem,
this.soundElem,
this.videoElem,
this.fileElem});
Message({
this.clientMsgID,
this.serverMsgID,
this.createTime,
this.sendTime,
this.sendID,
this.recvID,
this.msgFrom,
this.contentType,
this.platformID,
this.forceList,
this.senderNickName,
this.senderFaceUrl,
this.groupID,
this.content,
this.seq,
this.isRead,
this.status,
this.remark,
this.ext,
this.sessionType,
this.pictureElem,
this.soundElem,
this.videoElem,
this.fileElem,
this.atElem,
});
Message.fromJson(Map<String, dynamic> json)
/* : clientMsgID = json['clientMsgID']*/ {
@@ -61,7 +64,9 @@ class Message {
msgFrom = json['msgFrom'];
contentType = json['contentType'];
platformID = json['platformID'];
forceList = json['forceList'];
if (json['forceList'] is List) {
forceList = (json['forceList'] as List).map((e) => '$e').toList();
}
senderNickName = json['senderNickName'];
senderFaceUrl = json['senderFaceUrl'];
groupID = json['groupID'];
@@ -73,17 +78,17 @@ class Message {
ext = json['ext'];
sessionType = json['sessionType'];
pictureElem = json['pictureElem'] != null
? new PictureElem.fromJson(json['pictureElem'])
? PictureElem.fromJson(json['pictureElem'])
: null;
soundElem = json['soundElem'] != null
? new SoundElem.fromJson(json['soundElem'])
? SoundElem.fromJson(json['soundElem'])
: null;
videoElem = json['videoElem'] != null
? new VideoElem.fromJson(json['videoElem'])
: null;
fileElem = json['fileElem'] != null
? new FileElem.fromJson(json['fileElem'])
? VideoElem.fromJson(json['videoElem'])
: null;
fileElem =
json['fileElem'] != null ? FileElem.fromJson(json['fileElem']) : null;
atElem = json['atElem'] != null ? AtElem.fromJson(json['atElem']) : null;
}
Map<String, dynamic> toJson() {
@@ -120,6 +125,9 @@ class Message {
if (this.fileElem != null) {
data['fileElem'] = this.fileElem!.toJson();
}
if (this.atElem != null) {
data['atElem'] = this.atElem!.toJson();
}
return data;
}
@@ -335,3 +343,68 @@ class FileElem {
return data;
}
}
class AtElem {
String? text;
List<String>? atUserList;
bool? isAtSelf;
AtElem({this.text, this.atUserList, this.isAtSelf});
AtElem.fromJson(Map<String, dynamic> json) {
text = json['text'];
if (json['atUserList'] is List) {
atUserList = (json['atUserList'] as List).map((e) => '$e').toList();
}
isAtSelf = json['isAtSelf'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['atUserList'] = this.atUserList;
data['isAtSelf'] = this.isAtSelf;
return data;
}
}
class RevokeMessage {
String? serverMsgID;
String? sendID;
String? senderNickname;
String? recvID;
String? groupID;
int? contentType;
int? sendTime;
RevokeMessage(
{this.serverMsgID,
this.sendID,
this.senderNickname,
this.recvID,
this.groupID,
this.contentType,
this.sendTime});
RevokeMessage.fromJson(Map<String, dynamic> json) {
serverMsgID = json['serverMsgID'];
sendID = json['sendID'];
senderNickname = json['senderNickname'];
recvID = json['recvID'];
groupID = json['groupID'];
contentType = json['contentType'];
sendTime = json['sendTime'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['serverMsgID'] = this.serverMsgID;
data['sendID'] = this.sendID;
data['senderNickname'] = this.senderNickname;
data['recvID'] = this.recvID;
data['groupID'] = this.groupID;
data['contentType'] = this.contentType;
data['sendTime'] = this.sendTime;
return data;
}
}