Compare commits

...

7 Commits

Author SHA1 Message Date
hrxiang
39727feb8a Fix bug 2023-03-08 15:52:16 +08:00
hrxiang
c6d1669bdd 添加aar包本地依赖方式说明 2023-03-06 18:37:39 +08:00
hrxiang
02202051e1 添加aar包本地依赖方式说明 2023-03-06 18:36:38 +08:00
hrxiang
d0a4530314 New add 2023-03-03 15:17:40 +08:00
hrxiang
958c118e84 Fix bug for signaling 2023-03-01 11:44:14 +08:00
hrxiang
cdef7ffda8 Fix bug callback 'onUserTokenExpired' 2023-02-20 16:34:38 +08:00
hrxiang
bac4bd0884 Fix bug 2023-02-20 15:29:57 +08:00
18 changed files with 264 additions and 54 deletions

View File

@@ -1,3 +1,9 @@
## 2.3.5+3
- Fix bug for signaling
- Add networkChanged method
- Add setListenerForService method
## 2.3.5+2
- Add onRecvMessageExtensionsAdded method for OnAdvancedMsgListener

View File

@@ -1,6 +1,19 @@
group 'io.openim.flutter_openim_sdk'
version '1.0'
def dir = getCurrentProjectDir()
// 将aar放到libs本地仓库替换远程仓库
def getCurrentProjectDir() {
String result = ""
rootProject.allprojects { project ->
if (project.properties.get("name").toString() == "flutter_openim_sdk") {
result = project.properties.get("projectDir").toString()
}
}
return result
}
buildscript {
repositories {
google()
@@ -14,6 +27,8 @@ buildscript {
rootProject.allprojects {
repositories {
// 将aar放到libs本地仓库替换远程仓库
// maven { url "$dir/libs" }
maven { url 'https://open-im-online.rentsoft.cn:51000/repository/maven2/' }
google()
mavenCentral()
@@ -33,6 +48,9 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
api 'io.openim:core-sdk:2.3.5-t19@aar'
// 本地依赖现将aar复制到libs/io/openim/core-sdk/0.0.1/ 下命名core-sdk-0.0.1.aar
// implementation 'io.openim:core-sdk:0.0.1@aar'
api 'io.openim:core-sdk:2.3.5-t34@aar'
}

View File

@@ -0,0 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.openim</groupId>
<artifactId>core-sdk</artifactId>
<version>0.0.1</version>
</project>

View File

@@ -0,0 +1,30 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
public class OnListenerForService implements open_im_sdk_callback.OnListenerForService {
@Override
public void onFriendApplicationAccepted(String s) {
CommonUtil.emitEvent("listenerForService", "onFriendApplicationAccepted", s);
}
@Override
public void onFriendApplicationAdded(String s) {
CommonUtil.emitEvent("listenerForService", "onFriendApplicationAdded", s);
}
@Override
public void onGroupApplicationAccepted(String s) {
CommonUtil.emitEvent("listenerForService", "onGroupApplicationAccepted", s);
}
@Override
public void onGroupApplicationAdded(String s) {
CommonUtil.emitEvent("listenerForService", "onGroupApplicationAdded", s);
}
@Override
public void onRecvNewMessage(String s) {
CommonUtil.emitEvent("listenerForService", "onRecvNewMessage", s);
}
}

View File

@@ -4,6 +4,7 @@ import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.OnConnListener;
import io.openim.flutter_openim_sdk.listener.OnListenerForService;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk;
@@ -70,4 +71,18 @@ public class IMManager extends BaseManager {
value(methodCall, "isBackground")
);
}
public void networkChanged(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.networkChanged(
new OnBaseListener(result, methodCall),
value(methodCall, "operationID")
);
}
public void setListenerForService(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setListenerForService(new OnListenerForService());
result.success(null);
}
}

View File

@@ -16,6 +16,7 @@ export 'src/listener/conversation_listener.dart';
export 'src/listener/custom_business_listener.dart';
export 'src/listener/friendship_listener.dart';
export 'src/listener/group_listener.dart';
export 'src/listener/listener_for_service.dart';
export 'src/listener/message_kv_info_listener.dart';
export 'src/listener/msg_send_progress_listener.dart';
export 'src/listener/organization_listener.dart';

View File

@@ -1,16 +1,17 @@
/// callback类型
class ListenerType {
static final simpleMsgListener = 'simpleMsgListener';
static final connectListener = 'connectListener';
static final userListener = 'userListener';
static final groupListener = 'groupListener';
static final advancedMsgListener = 'advancedMsgListener';
static final conversationListener = 'conversationListener';
static final friendListener = 'friendListener';
static final signalingListener = 'signalingListener';
static final msgSendProgressListener = "msgSendProgressListener";
static final workMomentsListener = "workMomentsListener";
static final organizationListener = "organizationListener";
static final customBusinessListener = "customBusinessListener";
static final messageKvInfoListener = "messageKvInfoListener";
static const simpleMsgListener = 'simpleMsgListener';
static const connectListener = 'connectListener';
static const userListener = 'userListener';
static const groupListener = 'groupListener';
static const advancedMsgListener = 'advancedMsgListener';
static const conversationListener = 'conversationListener';
static const friendListener = 'friendListener';
static const signalingListener = 'signalingListener';
static const msgSendProgressListener = "msgSendProgressListener";
static const workMomentsListener = "workMomentsListener";
static const organizationListener = "organizationListener";
static const customBusinessListener = "customBusinessListener";
static const messageKvInfoListener = "messageKvInfoListener";
static const listenerForService = "listenerForService";
}

View File

@@ -4,38 +4,38 @@ class OnConnectListener {
Function()? onConnectSuccess;
Function()? onConnecting;
Function()? onKickedOffline;
Function()? onUserSigExpired;
Function()? onUserTokenExpired;
OnConnectListener({
this.onConnectFailed,
this.onConnectSuccess,
this.onConnecting,
this.onKickedOffline,
this.onUserSigExpired,
this.onUserTokenExpired,
});
/// SDK连接服务器失败
void connectFailed(int? code, String? errorMsg) {
if (null != onConnectFailed) onConnectFailed!(code, errorMsg);
onConnectFailed?.call(code, errorMsg);
}
/// SDK连接服务器成功
void connectSuccess() {
if (null != onConnectSuccess) onConnectSuccess!();
onConnectSuccess?.call();
}
/// SDK正在连接服务器
void connecting() {
if (null != onConnecting) onConnecting!.call();
onConnecting?.call();
}
/// 账号已在其他地方登录,当前设备被踢下线
void kickedOffline() {
if (null != onKickedOffline) onKickedOffline!();
onKickedOffline?.call();
}
/// 登录凭证过期,需要重新登录
void userSigExpired() {
if (null != onUserSigExpired) onUserSigExpired!();
void userTokenExpired() {
onUserTokenExpired?.call();
}
}

View File

@@ -20,29 +20,28 @@ class OnConversationListener {
/// 会话发生改变
void conversationChanged(List<ConversationInfo> list) {
if (onConversationChanged != null) onConversationChanged!(list);
onConversationChanged?.call(list);
}
/// 有新会话产生
void newConversation(List<ConversationInfo> list) {
if (onNewConversation != null) onNewConversation!(list);
onNewConversation?.call(list);
}
/// 未读消息总数发送改变
void totalUnreadMessageCountChanged(int i) {
if (onTotalUnreadMessageCountChanged != null)
onTotalUnreadMessageCountChanged!(i);
onTotalUnreadMessageCountChanged?.call(i);
}
void syncServerFailed() {
if (onSyncServerFailed != null) onSyncServerFailed!();
onSyncServerFailed?.call();
}
void syncServerFinish() {
if (onSyncServerFinish != null) onSyncServerFinish!();
onSyncServerFinish?.call();
}
void syncServerStart() {
if (onSyncServerStart != null) onSyncServerStart!();
onSyncServerStart?.call();
}
}

View File

@@ -0,0 +1,38 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
/// 好友关系监听
class OnListenerForService {
Function(FriendApplicationInfo i)? onFriendApplicationAdded;
Function(FriendApplicationInfo i)? onFriendApplicationAccepted;
Function(GroupApplicationInfo info)? onGroupApplicationAccepted;
Function(GroupApplicationInfo info)? onGroupApplicationAdded;
Function(Message msg)? onRecvNewMessage;
OnListenerForService({
this.onFriendApplicationAdded,
this.onFriendApplicationAccepted,
this.onGroupApplicationAccepted,
this.onGroupApplicationAdded,
this.onRecvNewMessage,
});
void friendApplicationAccepted(FriendApplicationInfo u) {
onFriendApplicationAccepted?.call(u);
}
void friendApplicationAdded(FriendApplicationInfo u) {
onFriendApplicationAdded?.call(u);
}
void groupApplicationAccepted(GroupApplicationInfo info) {
onGroupApplicationAccepted?.call(info);
}
void groupApplicationAdded(GroupApplicationInfo info) {
onGroupApplicationAdded?.call(info);
}
void recvNewMessage(Message msg) {
onRecvNewMessage?.call(msg);
}
}

View File

@@ -6,6 +6,6 @@ class OnMsgSendProgressListener {
/// 消息发送进度
void progress(String clientMsgID, int progress) {
if (null != onProgress) onProgress!(clientMsgID, progress);
onProgress?.call(clientMsgID, progress);
}
}

9
lib/src/logger.dart Normal file
View File

@@ -0,0 +1,9 @@
import 'dart:developer';
/// print full log
class Logger {
// Sample of abstract logging function
static void print(String text) {
log('** $text', name: 'flutter_openim_sdk');
}
}

View File

@@ -2,6 +2,7 @@ import 'dart:developer';
import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
import 'package:flutter_openim_sdk/src/logger.dart';
class IMManager {
MethodChannel _channel;
@@ -17,6 +18,7 @@ class IMManager {
late OrganizationManager organizationManager;
late OnConnectListener _connectListener;
OnListenerForService? _listenerForService;
late String uid;
late UserInfo uInfo;
bool isLogined = false;
@@ -39,7 +41,7 @@ class IMManager {
void _addNativeCallback(MethodChannel _channel) {
_channel.setMethodCallHandler((call) {
try {
log('Flutter : $call');
Logger.print('Flutter : $call');
if (call.method == ListenerType.connectListener) {
String type = call.arguments['type'];
switch (type) {
@@ -57,8 +59,8 @@ class IMManager {
case 'onKickedOffline':
_connectListener.kickedOffline();
break;
case 'onUserSigExpired':
_connectListener.userSigExpired();
case 'onUserTokenExpired':
_connectListener.userTokenExpired();
break;
}
} else if (call.method == ListenerType.userListener) {
@@ -353,10 +355,39 @@ class IMManager {
messageManager.messageKvInfoListener?.messageKvInfoChanged(list);
break;
}
} else if (call.method == ListenerType.listenerForService) {
String type = call.arguments['type'];
String data = call.arguments['data'];
switch (type) {
case 'onFriendApplicationAccepted':
final u = Utils.toObj(
data, (map) => FriendApplicationInfo.fromJson(map));
_listenerForService?.friendApplicationAccepted(u);
break;
case 'onFriendApplicationAdded':
final u = Utils.toObj(
data, (map) => FriendApplicationInfo.fromJson(map));
_listenerForService?.friendApplicationAdded(u);
break;
case 'onGroupApplicationAccepted':
final i = Utils.toObj(
data, (map) => GroupApplicationInfo.fromJson(map));
_listenerForService?.groupApplicationAccepted(i);
break;
case 'onGroupApplicationAdded':
final i = Utils.toObj(
data, (map) => GroupApplicationInfo.fromJson(map));
_listenerForService?.groupApplicationAdded(i);
break;
case 'onRecvNewMessage':
final msg = Utils.toObj(data, (map) => Message.fromJson(map));
_listenerForService?.recvNewMessage(msg);
break;
}
}
} catch (err) {
print(
"回调失败了。$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}");
} catch (error, stackTrace) {
Logger.print(
"回调失败了。${call.method} ${call.arguments['type']} ${call.arguments['data']} $error $stackTrace");
}
return Future.value(null);
});
@@ -414,10 +445,12 @@ class IMManager {
/// 登录
/// [uid] 用户id
/// [token] 登录token从业务服务器上获取
/// [defaultValue] 获取失败后使用的默认值
Future<UserInfo> login({
required String uid,
required String token,
String? operationID,
Future<UserInfo> Function()? defaultValue,
}) async {
await _channel.invokeMethod(
'login',
@@ -430,8 +463,16 @@ class IMManager {
this.isLogined = true;
this.uid = uid;
this.token = token;
this.uInfo = await userManager.getSelfUserInfo();
return uInfo;
try {
return this.uInfo = await userManager.getSelfUserInfo();
} catch (error, stackTrace) {
log('login e: $error s: $stackTrace');
if (null != defaultValue) {
return this.uInfo = await (defaultValue.call());
}
return Future.error(error, stackTrace);
}
// return uInfo;
}
/// 登出
@@ -507,6 +548,21 @@ class IMManager {
'operationID': Utils.checkOperationID(operationID),
}));
/// 网络改变
Future networkChanged({
String? operationID,
}) =>
_channel.invokeMethod(
'networkChanged',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}));
Future setListenerForService(OnListenerForService listener) {
this._listenerForService = listener;
return _channel.invokeMethod('setListenerForService', _buildParam({}));
}
MethodChannel get channel => _channel;
static Map _buildParam(Map param) {

View File

@@ -163,6 +163,9 @@ class SignalingManager {
required Map info,
String? operationID,
}) {
if (info['meetingID'] != null) {
info['roomID'] = info['meetingID'];
}
assert(info['roomID'] != null);
return _channel.invokeMethod(
'signalingUpdateMeetingInfo',

View File

@@ -20,7 +20,7 @@ class UserInfo {
/// 手机号
String? phoneNumber;
@deprecated
/// 使用[birthTime]
int? birth;
/// 出生时间
@@ -288,7 +288,7 @@ class FriendInfo {
/// 出生日期
String? birthTime;
@deprecated
/// 使用[birthTime]
int? birth;
/// 邮箱

View File

@@ -2,7 +2,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OpenIM {
static const version = '2.3.5+2';
static const version = '2.3.5+3';
static const _channel = const MethodChannel('flutter_openim_sdk');

View File

@@ -5,20 +5,23 @@ packages:
dependency: transitive
description:
name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.9.0"
version: "2.10.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
@@ -26,6 +29,7 @@ packages:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
@@ -33,13 +37,15 @@ packages:
dependency: transitive
description:
name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.16.0"
version: "1.17.0"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
@@ -53,24 +59,35 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.5"
matcher:
dependency: transitive
description:
name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.12"
version: "0.12.13"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.5"
version: "0.2.0"
meta:
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
@@ -78,6 +95,7 @@ packages:
dependency: transitive
description:
name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.2"
@@ -90,34 +108,39 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.0"
version: "1.9.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0"
version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
version: "2.1.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.1"
@@ -125,16 +148,18 @@ packages:
dependency: transitive
description:
name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.12"
version: "0.4.16"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.2"
version: "2.1.4"
sdks:
dart: ">=2.17.0-0 <3.0.0"
dart: ">=2.18.0 <3.0.0"
flutter: ">=1.20.0"

View File

@@ -1,6 +1,6 @@
name: flutter_openim_sdk
description: An instant messaging plug-in that supports Android and IOS. And the server is also all open source.
version: 2.3.5+2
version: 2.3.5+3
homepage: https://www.rentsoft.cn
repository: https://github.com/OpenIMSDK/Open-IM-SDK-Flutter