Add some new function

This commit is contained in:
hrxiang
2022-10-25 11:45:30 +08:00
parent a77c86e87a
commit b8ee9276a2
15 changed files with 553 additions and 12 deletions

View File

@@ -31,6 +31,7 @@ export 'src/manager/im_user_manager.dart';
export 'src/manager/im_workmoments_manager.dart';
export 'src/models/conversation_info.dart';
export 'src/models/group_info.dart';
export 'src/models/meeting_info.dart';
export 'src/models/message.dart';
export 'src/models/notification_info.dart';
export 'src/models/organization_info.dart';

View File

@@ -1,4 +1,4 @@
import 'package:flutter_openim_sdk/src/models/signaling_info.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
/// 信令监听
class OnSignalingListener {
@@ -12,6 +12,7 @@ class OnSignalingListener {
final Function(SignalingInfo info)? onHangup;
final Function(RoomCallingInfo info)? onRoomParticipantConnected;
final Function(RoomCallingInfo info)? onRoomParticipantDisconnected;
final Function(MeetingStreamEvent event)? onMeetingStreamChanged;
OnSignalingListener({
this.onInvitationCancelled,
@@ -24,6 +25,7 @@ class OnSignalingListener {
this.onHangup,
this.onRoomParticipantConnected,
this.onRoomParticipantDisconnected,
this.onMeetingStreamChanged,
});
/// 被邀请者收到:邀请者取消音视频通话
@@ -73,4 +75,8 @@ class OnSignalingListener {
void roomParticipantDisconnected(RoomCallingInfo info) {
onRoomParticipantDisconnected?.call(info);
}
void streamChangedEvent(MeetingStreamEvent event) {
onMeetingStreamChanged?.call(event);
}
}

View File

@@ -250,6 +250,10 @@ class IMManager {
case 'onRoomParticipantDisconnected':
info = Utils.toObj(data, (map) => RoomCallingInfo.fromJson(map));
break;
case 'onStreamChange':
info =
Utils.toObj(data, (map) => MeetingStreamEvent.fromJson(map));
break;
default:
info = Utils.toObj(data, (map) => SignalingInfo.fromJson(map));
break;
@@ -285,6 +289,9 @@ class IMManager {
case 'onRoomParticipantDisconnected':
signalingManager.listener.roomParticipantDisconnected(info);
break;
case 'onStreamChange':
signalingManager.listener.streamChangedEvent(info);
break;
}
} else if (call.method == ListenerType.workMomentsListener) {
String type = call.arguments['type'];

View File

@@ -735,18 +735,14 @@ class MessageManager {
/// [conversationID] 会话id
/// [clientMsgIDList] 消息id列表
Future<SearchResult> findMessageList({
required String conversationID,
required List<String> clientMsgIDList,
required List<SearchParams> searchParams,
String? operationID,
}) =>
_channel
.invokeMethod(
'findMessageList',
_buildParam({
'options': {
"conversationID": conversationID,
"clientMsgIDList": clientMsgIDList,
},
'searchParams': searchParams.map((e) => e.toJson()),
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
@@ -792,6 +788,92 @@ class MessageManager {
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// 发送消息
/// [message] 消息体 [createImageMessageByURL],[createSoundMessageByURL],[createVideoMessageByURL],[createFileMessageByURL]
/// [userID] 接收消息的用户id
/// [groupID] 接收消息的组id
/// [offlinePushInfo] 离线消息显示内容
Future<Message> sendMessageNotOss({
required Message message,
required OfflinePushInfo offlinePushInfo,
String? userID,
String? groupID,
String? operationID,
}) =>
_channel
.invokeMethod(
'sendMessageNotOss',
_buildParam({
'message': message.toJson(),
'offlinePushInfo': offlinePushInfo.toJson(),
'userID': userID ?? '',
'groupID': groupID ?? '',
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// 创建图片消息
Future<Message> createImageMessageByURL({
required PictureInfo sourcePicture,
required PictureInfo bigPicture,
required PictureInfo snapshotPicture,
String? operationID,
}) =>
_channel
.invokeMethod(
'createImageMessageByURL',
_buildParam({
'sourcePicture': sourcePicture,
'bigPicture': bigPicture,
'snapshotPicture': snapshotPicture,
"operationID": Utils.checkOperationID(operationID),
}),
)
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// 创建语音消息
Future<Message> createSoundMessageByURL({
required SoundElem soundElem,
String? operationID,
}) =>
_channel
.invokeMethod(
'createSoundMessageByURL',
_buildParam({
'soundElem': soundElem,
"operationID": Utils.checkOperationID(operationID),
}),
)
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// 创建视频消息
Future<Message> createVideoMessageByURL({
required VideoElem videoElem,
String? operationID,
}) =>
_channel
.invokeMethod(
'createVideoMessageByURL',
_buildParam({
'videoElem': videoElem,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// 创建视频消息
Future<Message> createFileMessageByURL({
required FileElem fileElem,
String? operationID,
}) =>
_channel
.invokeMethod(
'createFileMessageByURL',
_buildParam({
'fileElem': fileElem,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
static Map _buildParam(Map param) {
param["ManagerName"] = "messageManager";
return param;

View File

@@ -135,6 +135,152 @@ class SignalingManager {
(map) => SignalingCertificate.fromJson(
map..addAll({'roomID': roomID}))));
/// 会议设置
/// required String roomID,
/// String? meetingName,
/// String? ex,
/// int startTime = 0,
/// int endTime = 0,
/// bool participantCanUnmuteSelf = true,
/// bool participantCanEnableVideo = true,
/// bool onlyHostInviteUser = true,
/// bool onlyHostShareScreen = true,
/// bool joinDisableMicrophone = true,
/// bool joinDisableVideo = true,
/// bool isMuteAllVideo = true,
/// bool isMuteAllMicrophone = true,
/// List<String> addCanScreenUserIDList = const [],
/// List<String> reduceCanScreenUserIDList = const [],
/// List<String> addDisableMicrophoneUserIDList = const [],
/// List<String> reduceDisableMicrophoneUserIDList = const [],
/// List<String> addDisableVideoUserIDList = const [],
/// List<String> reduceDisableVideoUserIDList = const [],
/// List<String> addPinedUserIDList = const [],
/// List<String> reducePinedUserIDList = const [],
/// List<String> addBeWatchedUserIDList = const [],
/// List<String> reduceBeWatchedUserIDList = const [],
Future<dynamic> signalingUpdateMeetingInfo({
required Map info,
String? operationID,
}) {
assert(info['roomID'] != null);
return _channel.invokeMethod(
'signalingUpdateMeetingInfo',
_buildParam({
'info': info,
'operationID': Utils.checkOperationID(operationID),
}));
}
/// 创建会议室
/// [meetingName] 会议主题
/// [meetingHostUserID] 会议主持人ID
/// [startTime] 开始时间s
/// [meetingDuration] 会议时长s
/// [inviteeUserIDList] 被邀请人ID列表
/// [ex] 其他
Future<SignalingCertificate> signalingCreateMeeting({
required String meetingName,
String? meetingHostUserID,
int? startTime,
int? meetingDuration,
List<String> inviteeUserIDList = const [],
String? ex,
String? operationID,
}) =>
_channel
.invokeMethod(
'signalingCreateMeeting',
_buildParam({
'info': {
'meetingName': meetingName,
'meetingHostUserID': meetingHostUserID,
'startTime': startTime,
'meetingDuration': meetingDuration,
'inviteeUserIDList': inviteeUserIDList,
'ex': ex,
},
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toObj(value, (map) => SignalingCertificate.fromJson(map)));
/// 加入会议室
/// [meetingID] 会议ID
/// [meetingName] 会议主题
/// [participantNickname] 加入房间显示的名称
Future<SignalingCertificate> signalingJoinMeeting({
required String meetingID,
String? meetingName,
String? participantNickname,
String? operationID,
}) =>
_channel
.invokeMethod(
'signalingJoinMeeting',
_buildParam({
'info': {
'meetingID': meetingID,
'meetingName': meetingName,
'participantNickname': participantNickname,
},
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toObj(value, (map) => SignalingCertificate.fromJson(map)));
/// 会议室 管理员对指定的某一个入会人员设置禁言
/// [roomID] 会议ID
/// [streamType] video/audio
/// [userID] 被禁言的用户ID
/// [mute] true禁言
/// [muteAll] truevideo/audio 一起设置
Future<dynamic> signalingOperateStream({
required String roomID,
String? streamType,
required String userID,
bool mute = false,
bool muteAll = false,
String? operationID,
}) =>
_channel.invokeMethod(
'signalingOperateStream',
_buildParam({
'roomID': roomID,
'streamType': streamType,
'userID': userID,
'mute': mute,
'muteAll': muteAll,
'operationID': Utils.checkOperationID(operationID),
}));
/// 获取所有的未完成会议
/// [roomID] 会议ID
Future<MeetingInfoList> signalingGetMeetings({
String? operationID,
}) =>
_channel
.invokeMethod(
'signalingGetMeetings',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toObj(value, (map) => MeetingInfoList.fromJson(map)));
/// 结束会议
/// [roomID] 会议ID
Future<dynamic> signalingCloseRoom({
required String roomID,
String? operationID,
}) =>
_channel.invokeMethod(
'signalingCloseRoom',
_buildParam({
'roomID': roomID,
'operationID': Utils.checkOperationID(operationID),
}));
static Map _buildParam(Map param) {
param["ManagerName"] = "signalingManager";
return param;

View File

@@ -0,0 +1,106 @@
class MeetingInfoList {
List<MeetingInfo>? meetingInfoList;
MeetingInfoList({this.meetingInfoList});
MeetingInfoList.fromJson(Map<String, dynamic> json) {
if (json['meetingInfoList'] != null) {
meetingInfoList = <MeetingInfo>[];
json['meetingInfoList'].forEach((v) {
meetingInfoList!.add(MeetingInfo.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
if (this.meetingInfoList != null) {
data['meetingInfoList'] =
this.meetingInfoList!.map((v) => v.toJson()).toList();
}
return data;
}
}
class MeetingInfo {
String? meetingID;
String? meetingName;
String? hostUserID;
int? createTime;
int? startTime;
int? endTime;
bool? participantCanEnableVideo;
bool? onlyHostInviteUser;
bool? joinDisableVideo;
bool? participantCanUnmuteSelf;
bool? isMuteAllMicrophone;
List<String>? inviteeUserIDList;
MeetingInfo(
{this.meetingID,
this.meetingName,
this.hostUserID,
this.createTime,
this.startTime,
this.endTime,
this.participantCanEnableVideo,
this.onlyHostInviteUser,
this.joinDisableVideo,
this.participantCanUnmuteSelf,
this.isMuteAllMicrophone,
this.inviteeUserIDList});
MeetingInfo.fromJson(Map<String, dynamic> json) {
meetingID = json['meetingID'];
meetingName = json['meetingName'];
hostUserID = json['hostUserID'];
createTime = json['createTime'];
startTime = json['startTime'];
endTime = json['endTime'];
participantCanEnableVideo = json['participantCanEnableVideo'];
onlyHostInviteUser = json['onlyHostInviteUser'];
joinDisableVideo = json['joinDisableVideo'];
participantCanUnmuteSelf = json['participantCanUnmuteSelf'];
isMuteAllMicrophone = json['isMuteAllMicrophone'];
inviteeUserIDList = json['inviteeUserIDList']?.cast<String>();
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['meetingID'] = this.meetingID;
data['meetingName'] = this.meetingName;
data['hostUserID'] = this.hostUserID;
data['createTime'] = this.createTime;
data['startTime'] = this.startTime;
data['endTime'] = this.endTime;
data['participantCanEnableVideo'] = this.participantCanEnableVideo;
data['onlyHostInviteUser'] = this.onlyHostInviteUser;
data['joinDisableVideo'] = this.joinDisableVideo;
data['participantCanUnmuteSelf'] = this.participantCanUnmuteSelf;
data['isMuteAllMicrophone'] = this.isMuteAllMicrophone;
data['inviteeUserIDList'] = this.inviteeUserIDList;
return data;
}
}
class MeetingStreamEvent {
String? meetingID;
String? streamType;
bool? mute;
MeetingStreamEvent({this.meetingID, this.streamType, this.mute});
MeetingStreamEvent.fromJson(Map<String, dynamic> json) {
meetingID = json['meetingID'];
streamType = json['streamType'];
mute = json['mute'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['meetingID'] = this.meetingID;
data['streamType'] = this.streamType;
data['mute'] = this.mute;
return data;
}
}

View File

@@ -78,3 +78,27 @@ class SearchResultItems {
return data;
}
}
class SearchParams {
String? conversationID;
List<String>? clientMsgIDList;
SearchParams({
this.conversationID,
this.clientMsgIDList,
});
SearchParams.fromJson(Map<String, dynamic> json) {
conversationID = json['conversationID'];
if (json['clientMsgIDList'] != null) {
clientMsgIDList = json['clientMsgIDList'].cast<String>();
}
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['conversationID'] = this.conversationID;
data['messageCount'] = this.clientMsgIDList;
return data;
}
}