new add map,file message
This commit is contained in:
@@ -7,6 +7,9 @@ class MessageType {
|
||||
static const file = 105;
|
||||
static const at_text = 106;
|
||||
static const merger = 107;
|
||||
static const forward = 108;
|
||||
static const location = 109;
|
||||
static const custom = 110;
|
||||
static const revoke = 111;
|
||||
static const has_read_receipt = 112;
|
||||
static const typing = 113;
|
||||
@@ -18,12 +21,12 @@ class MessageType {
|
||||
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;
|
||||
|
||||
@@ -8,7 +8,7 @@ class InitSDKListener {
|
||||
void onConnectSuccess() {}
|
||||
|
||||
/// SDK 连接服务器失败
|
||||
void onConnectFailed(int? int, String? errorMsg) {}
|
||||
void onConnectFailed(int? code, String? errorMsg) {}
|
||||
|
||||
/// 当前用户被踢下线,此时可以 UI 提示用户,并再次调用 IMManager 的 login() 函数重新登录。
|
||||
void onKickedOffline() {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
@@ -194,6 +195,15 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
Future<Message> createImageMessageFromFullPath({required String imagePath}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createImageMessageFromFullPath',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createSoundMessage({
|
||||
required String soundPath,
|
||||
@@ -207,6 +217,18 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
Future<Message> createSoundMessageFromFullPath({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createSoundMessageFromFullPath',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createVideoMessage({
|
||||
required String videoPath,
|
||||
@@ -226,6 +248,24 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
Future<Message> createVideoMessageFromFullPath({
|
||||
required String videoPath,
|
||||
required String videoType,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createVideoMessageFromFullPath',
|
||||
_buildParam({
|
||||
'videoPath': videoPath,
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<Message> createFileMessage({
|
||||
required String filePath,
|
||||
@@ -269,6 +309,38 @@ class MessageManager {
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
Future<Message> createLocationMessage({
|
||||
required double latitude,
|
||||
required double longitude,
|
||||
required String description,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createLocationMessage',
|
||||
_buildParam({
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'description': description,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
Future<Message> createCustomMessage({
|
||||
required Uint8List data,
|
||||
required Uint8List extension,
|
||||
required String description,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createCustomMessage',
|
||||
_buildParam({
|
||||
'data': data,
|
||||
'extension': extension,
|
||||
'description': description,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
///
|
||||
Future<dynamic> getTotalUnreadMsgCount() {
|
||||
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
class Message {
|
||||
String? clientMsgID;
|
||||
String? serverMsgID;
|
||||
@@ -24,6 +26,8 @@ class Message {
|
||||
VideoElem? videoElem;
|
||||
FileElem? fileElem;
|
||||
AtElem? atElem;
|
||||
LocationElem? locationElem;
|
||||
CustomElem? customElem;
|
||||
|
||||
Message({
|
||||
this.clientMsgID,
|
||||
@@ -51,6 +55,8 @@ class Message {
|
||||
this.videoElem,
|
||||
this.fileElem,
|
||||
this.atElem,
|
||||
this.locationElem,
|
||||
this.customElem,
|
||||
});
|
||||
|
||||
Message.fromJson(Map<String, dynamic> json)
|
||||
@@ -89,6 +95,13 @@ class Message {
|
||||
fileElem =
|
||||
json['fileElem'] != null ? FileElem.fromJson(json['fileElem']) : null;
|
||||
atElem = json['atElem'] != null ? AtElem.fromJson(json['atElem']) : null;
|
||||
locationElem = json['locationElem'] != null
|
||||
? LocationElem.fromJson(json['locationElem'])
|
||||
: null;
|
||||
|
||||
customElem = json['customElem'] != null
|
||||
? CustomElem.fromJson(json['customElem'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -113,21 +126,13 @@ class Message {
|
||||
data['remark'] = this.remark;
|
||||
data['ext'] = this.ext;
|
||||
data['sessionType'] = this.sessionType;
|
||||
if (this.pictureElem != null) {
|
||||
data['pictureElem'] = this.pictureElem!.toJson();
|
||||
}
|
||||
if (this.soundElem != null) {
|
||||
data['soundElem'] = this.soundElem!.toJson();
|
||||
}
|
||||
if (this.videoElem != null) {
|
||||
data['videoElem'] = this.videoElem!.toJson();
|
||||
}
|
||||
if (this.fileElem != null) {
|
||||
data['fileElem'] = this.fileElem!.toJson();
|
||||
}
|
||||
if (this.atElem != null) {
|
||||
data['atElem'] = this.atElem!.toJson();
|
||||
}
|
||||
data['pictureElem'] = this.pictureElem?.toJson();
|
||||
data['soundElem'] = this.soundElem?.toJson();
|
||||
data['videoElem'] = this.videoElem?.toJson();
|
||||
data['fileElem'] = this.fileElem?.toJson();
|
||||
data['atElem'] = this.atElem?.toJson();
|
||||
data['locationElem'] = this.locationElem?.toJson();
|
||||
data['customElem'] = this.customElem?.toJson();
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -368,6 +373,59 @@ class AtElem {
|
||||
}
|
||||
}
|
||||
|
||||
class LocationElem {
|
||||
String? description;
|
||||
double? longitude;
|
||||
double? latitude;
|
||||
|
||||
LocationElem({this.description, this.longitude, this.latitude});
|
||||
|
||||
LocationElem.fromJson(Map<String, dynamic> json) {
|
||||
description = json['description'];
|
||||
if (json['longitude'] is int) {
|
||||
longitude = (json['longitude'] as int).toDouble();
|
||||
} else {
|
||||
longitude = json['longitude'];
|
||||
}
|
||||
|
||||
if (json['latitude'] is int) {
|
||||
latitude = (json['latitude'] as int).toDouble();
|
||||
} else {
|
||||
latitude = json['latitude'];
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['description'] = this.description;
|
||||
data['longitude'] = this.longitude;
|
||||
data['latitude'] = this.latitude;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class CustomElem {
|
||||
Uint8List? data;
|
||||
Uint8List? extension;
|
||||
String? description;
|
||||
|
||||
CustomElem({this.data, this.extension, this.description});
|
||||
|
||||
CustomElem.fromJson(Map<String, dynamic> json) {
|
||||
data = json['data'];
|
||||
extension = json['extension'];
|
||||
description = json['description'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['data'] = this.data;
|
||||
data['extension'] = this.extension;
|
||||
data['description'] = this.description;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class HaveReadInfo {
|
||||
String? uid;
|
||||
List<String>? msgIDList;
|
||||
@@ -376,13 +434,12 @@ class HaveReadInfo {
|
||||
int? contentType;
|
||||
int? sessionType;
|
||||
|
||||
HaveReadInfo(
|
||||
{this.uid,
|
||||
this.msgIDList,
|
||||
this.readTime,
|
||||
this.msgFrom,
|
||||
this.contentType,
|
||||
this.sessionType});
|
||||
HaveReadInfo({this.uid,
|
||||
this.msgIDList,
|
||||
this.readTime,
|
||||
this.msgFrom,
|
||||
this.contentType,
|
||||
this.sessionType});
|
||||
|
||||
HaveReadInfo.fromJson(Map<String, dynamic> json) {
|
||||
uid = json['uid'];
|
||||
|
||||
Reference in New Issue
Block a user