new add map,file message
This commit is contained in:
parent
a63fd8966a
commit
ebbbf4661c
@ -52,5 +52,5 @@ android {
|
||||
}
|
||||
dependencies {
|
||||
// implementation 'io.openim:client:0.0.13@aar'
|
||||
implementation 'io.openim:client-sdk:0.0.4@aar'
|
||||
implementation 'io.openim:client-sdk:0.0.5@aar'
|
||||
}
|
@ -11,7 +11,7 @@ public class IMManager {
|
||||
|
||||
public void initSDK(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.initSDK(CommonUtil.getSDKJsonParam(methodCall), new SDKListener());
|
||||
CommonUtil.runMainThreadReturn(result, null);
|
||||
// CommonUtil.runMainThreadReturn(result, null);
|
||||
}
|
||||
|
||||
public void login(MethodCall methodCall, MethodChannel.Result result) {
|
||||
|
@ -106,6 +106,12 @@ public class MessageManager {
|
||||
CommonUtil.getImagePath(methodCall)));
|
||||
}
|
||||
|
||||
public void createImageMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createImageMessageFromFullPath(
|
||||
CommonUtil.getImagePath(methodCall)));
|
||||
}
|
||||
|
||||
public void createSoundMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createSoundMessage(
|
||||
@ -113,6 +119,13 @@ public class MessageManager {
|
||||
CommonUtil.getSoundDuration(methodCall)));
|
||||
}
|
||||
|
||||
public void createSoundMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createSoundMessageFromFullPath(
|
||||
CommonUtil.getSoundPath(methodCall),
|
||||
CommonUtil.getSoundDuration(methodCall)));
|
||||
}
|
||||
|
||||
public void createVideoMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createVideoMessage(
|
||||
@ -122,6 +135,15 @@ public class MessageManager {
|
||||
CommonUtil.getVideoSnapshotPath(methodCall)));
|
||||
}
|
||||
|
||||
public void createVideoMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createVideoMessageFromFullPath(
|
||||
CommonUtil.getVideoPath(methodCall),
|
||||
CommonUtil.getVideoType(methodCall),
|
||||
CommonUtil.getVideoDuration(methodCall),
|
||||
CommonUtil.getVideoSnapshotPath(methodCall)));
|
||||
}
|
||||
|
||||
public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createFileMessage(
|
||||
@ -137,12 +159,29 @@ public class MessageManager {
|
||||
CommonUtil.getSummaryList(methodCall)));
|
||||
}
|
||||
|
||||
|
||||
public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result,
|
||||
Open_im_sdk.createForwardMessage(
|
||||
CommonUtil.getForwardMessage(methodCall)));
|
||||
}
|
||||
|
||||
public void createLocationMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createLocationMessage(
|
||||
CommonUtil.getMessageDes(methodCall),
|
||||
CommonUtil.getLocationLongitude(methodCall),
|
||||
CommonUtil.getLocationLatitude(methodCall)
|
||||
));
|
||||
}
|
||||
|
||||
public void createCustomMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createCustomMessage(
|
||||
CommonUtil.getCustomMessageData(methodCall),
|
||||
CommonUtil.getCustomMessageExt(methodCall),
|
||||
CommonUtil.getMessageDes(methodCall)
|
||||
));
|
||||
}
|
||||
|
||||
public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result));
|
||||
}
|
||||
|
@ -263,6 +263,27 @@ public class CommonUtil {
|
||||
return getSDKJsonParam(methodCall, KEY_GROUP_APPLICATION_INFO);
|
||||
}
|
||||
|
||||
|
||||
public static double getLocationLatitude(MethodCall methodCall) {
|
||||
return getParamValue(methodCall, KEY_LOCATION_MESSAGE_LA);
|
||||
}
|
||||
|
||||
public static double getLocationLongitude(MethodCall methodCall) {
|
||||
return getParamValue(methodCall, KEY_LOCATION_MESSAGE_LO);
|
||||
}
|
||||
|
||||
public static String getMessageDes(MethodCall methodCall) {
|
||||
return getParamValue(methodCall, KEY_MESSAGE_DES);
|
||||
}
|
||||
|
||||
public static byte[] getCustomMessageData(MethodCall methodCall) {
|
||||
return getParamValue(methodCall, KEY_CUSTOM_MESSAGE_DATA);
|
||||
}
|
||||
|
||||
public static byte[] getCustomMessageExt(MethodCall methodCall) {
|
||||
return getParamValue(methodCall, KEY_CUSTOM_MESSAGE_EXT);
|
||||
}
|
||||
|
||||
//login
|
||||
final static String KEY_UID = "uid";
|
||||
final static String KEY_TOKEN = "token";
|
||||
@ -282,6 +303,11 @@ public class CommonUtil {
|
||||
final static String KEY_MERGER_MESSAGE_TITLE = "title";
|
||||
final static String KEY_SUMMARY_LIST = "summaryList";
|
||||
final static String KEY_FORWARD_MESSAGE = "message";
|
||||
final static String KEY_LOCATION_MESSAGE_LO = "longitude";
|
||||
final static String KEY_LOCATION_MESSAGE_LA = "latitude";
|
||||
final static String KEY_MESSAGE_DES = "description";
|
||||
final static String KEY_CUSTOM_MESSAGE_DATA = "data";
|
||||
final static String KEY_CUSTOM_MESSAGE_EXT = "extension";
|
||||
//send message
|
||||
final static String KEY_SEND_MESSAGE_CONTENT = "message";
|
||||
final static String KEY_SEND_MESSAGE_CONTENT_CLIENT_ID = "clientMsgID";
|
||||
|
@ -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,8 +434,7 @@ class HaveReadInfo {
|
||||
int? contentType;
|
||||
int? sessionType;
|
||||
|
||||
HaveReadInfo(
|
||||
{this.uid,
|
||||
HaveReadInfo({this.uid,
|
||||
this.msgIDList,
|
||||
this.readTime,
|
||||
this.msgFrom,
|
||||
|
Loading…
x
Reference in New Issue
Block a user