hrxiang 4 years ago
parent c15773e28c
commit 9ac48d065a
  1. 16
      android/build.gradle
  2. 16
      android/src/main/java/io/openim/flutter_openim_sdk/manager/GroupManager.java
  3. 4
      android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java
  4. 4
      android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java
  5. 1
      lib/flutter_openim_sdk.dart
  6. 6
      lib/src/enum/message_status.dart
  7. 28
      lib/src/enum/message_type.dart
  8. 22
      lib/src/manager/im_group_manager.dart
  9. 23
      lib/src/manager/im_manager.dart
  10. 4
      lib/src/manager/im_message_manager.dart
  11. 21
      lib/src/models/group_info.dart
  12. 137
      lib/src/models/message.dart
  13. 29
      test/flutter_openim_sdk_test.dart

@ -7,11 +7,9 @@ buildscript {
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { url 'http://47.112.160.66:8081/repository/maven-releases'}
maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
google()
maven {
url 'http://47.112.160.66:8081/repository/maven-releases'
// url 'http://127.0.0.1:8081/repository/maven-releases/'
}
mavenCentral()
}
@ -26,11 +24,9 @@ rootProject.allprojects {
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { url 'http://47.112.160.66:8081/repository/maven-releases'}
maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
google()
maven {
url 'http://47.112.160.66:8081/repository/maven-releases'
// url 'http://127.0.0.1:8081/repository/maven-releases'
}
mavenCentral()
}
}
@ -49,6 +45,6 @@ android {
}
}
dependencies {
// implementation 'io.openim:localsdk:1.2.9@aar'
implementation 'io.openim:client-sdk:1.0.0@aar'//graoupId:artifactId:version@aar
implementation 'io.openim:client-sdk:0.0.1@aar'
// implementation 'io.openim:client-sdk:1.0.0@aar'//graoupId:artifactId:version@aar
}

@ -107,4 +107,20 @@ public class GroupManager {
new BaseListener(result));
}
public void forceSyncApplyGroupRequest(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncApplyGroupRequest();
}
public void forceSyncGroupRequest(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncGroupRequest();
}
public void forceSyncJoinedGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncJoinedGroup();
}
public void forceSyncJoinedGroupMember(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncJoinedGroupMember();
}
}

@ -41,4 +41,8 @@ public class IMManager {
public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncLoginUerInfo();
}
public void forceReConn(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceReConn();
}
}

@ -139,4 +139,8 @@ public class MessageManager {
public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result));
}
public void forceSyncMsg(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncMsg();
}
}

@ -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';

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

@ -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 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;
}

@ -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;

@ -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;

@ -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;

@ -75,14 +75,17 @@ class GroupMembersInfo {
int? joinTime;
String? nickName;
String? faceUrl;
GroupMembersInfo(
{this.groupID,
this.userId,
this.role,
this.joinTime,
this.nickName,
this.faceUrl});
dynamic ext;
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;
}
}

@ -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;
}
}

@ -1,4 +1,4 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
import 'dart:convert';
void main() {
/* const MethodChannel channel = MethodChannel('flutter_openim_sdk');
@ -17,14 +17,21 @@ void main() {
test('getPlatformVersion', () async {});*/
Message m1 = new Message(clientMsgID: '1', content: 'c1');
Message m2 = new Message(clientMsgID: '2', content: 'c2');
Message m3 = new Message(clientMsgID: '3', content: 'c3');
Message m4 = new Message(clientMsgID: '3', content: 'c4');
List list = List.of([m1, m2, m3]);
print(list.contains(m4));
print(m1 == m4);
print(m2 == m4);
print(m3 == m4);
// Message m1 = new Message(clientMsgID: '1', content: 'c1');
// Message m2 = new Message(clientMsgID: '2', content: 'c2');
// Message m3 = new Message(clientMsgID: '3', content: 'c3');
// Message m4 = new Message(clientMsgID: '3', content: 'c4');
// List list = List.of([m1, m2, m3]);
//
// print(list.contains(m4));
// print(m1 == m4);
// print(m2 == m4);
// print(m3 == m4);
var input = "1234 @abc @bbc @hha 开什么玩笑";
RegExp exp = new RegExp(r"(@\w+) ");
final ms = exp.allMatches(input);
for (Match m in ms) {
String match = m.group(0)??'';
print('====$match ${m.start} ${m.end}');
}
}

Loading…
Cancel
Save