New add
This commit is contained in:
parent
958c118e84
commit
d0a4530314
@ -1,6 +1,8 @@
|
|||||||
## 2.3.5+2
|
## 2.3.5+3
|
||||||
|
|
||||||
- Fix bug for signaling
|
- Fix bug for signaling
|
||||||
|
- Add networkChanged method
|
||||||
|
- Add setListenerForService method
|
||||||
|
|
||||||
## 2.3.5+2
|
## 2.3.5+2
|
||||||
|
|
||||||
|
@ -34,5 +34,5 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
api 'io.openim:core-sdk:2.3.5-t27@aar'
|
api 'io.openim:core-sdk:2.3.5-t30@aar'
|
||||||
}
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import io.flutter.plugin.common.MethodCall;
|
|||||||
import io.flutter.plugin.common.MethodChannel;
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
import io.openim.flutter_openim_sdk.listener.OnBaseListener;
|
import io.openim.flutter_openim_sdk.listener.OnBaseListener;
|
||||||
import io.openim.flutter_openim_sdk.listener.OnConnListener;
|
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 io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||||
import open_im_sdk.Open_im_sdk;
|
import open_im_sdk.Open_im_sdk;
|
||||||
|
|
||||||
@ -70,4 +71,18 @@ public class IMManager extends BaseManager {
|
|||||||
value(methodCall, "isBackground")
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ export 'src/listener/conversation_listener.dart';
|
|||||||
export 'src/listener/custom_business_listener.dart';
|
export 'src/listener/custom_business_listener.dart';
|
||||||
export 'src/listener/friendship_listener.dart';
|
export 'src/listener/friendship_listener.dart';
|
||||||
export 'src/listener/group_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/message_kv_info_listener.dart';
|
||||||
export 'src/listener/msg_send_progress_listener.dart';
|
export 'src/listener/msg_send_progress_listener.dart';
|
||||||
export 'src/listener/organization_listener.dart';
|
export 'src/listener/organization_listener.dart';
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
/// callback类型
|
/// callback类型
|
||||||
class ListenerType {
|
class ListenerType {
|
||||||
static final simpleMsgListener = 'simpleMsgListener';
|
static const simpleMsgListener = 'simpleMsgListener';
|
||||||
static final connectListener = 'connectListener';
|
static const connectListener = 'connectListener';
|
||||||
static final userListener = 'userListener';
|
static const userListener = 'userListener';
|
||||||
static final groupListener = 'groupListener';
|
static const groupListener = 'groupListener';
|
||||||
static final advancedMsgListener = 'advancedMsgListener';
|
static const advancedMsgListener = 'advancedMsgListener';
|
||||||
static final conversationListener = 'conversationListener';
|
static const conversationListener = 'conversationListener';
|
||||||
static final friendListener = 'friendListener';
|
static const friendListener = 'friendListener';
|
||||||
static final signalingListener = 'signalingListener';
|
static const signalingListener = 'signalingListener';
|
||||||
static final msgSendProgressListener = "msgSendProgressListener";
|
static const msgSendProgressListener = "msgSendProgressListener";
|
||||||
static final workMomentsListener = "workMomentsListener";
|
static const workMomentsListener = "workMomentsListener";
|
||||||
static final organizationListener = "organizationListener";
|
static const organizationListener = "organizationListener";
|
||||||
static final customBusinessListener = "customBusinessListener";
|
static const customBusinessListener = "customBusinessListener";
|
||||||
static final messageKvInfoListener = "messageKvInfoListener";
|
static const messageKvInfoListener = "messageKvInfoListener";
|
||||||
|
static const listenerForService = "listenerForService";
|
||||||
}
|
}
|
||||||
|
38
lib/src/listener/listener_for_service.dart
Normal file
38
lib/src/listener/listener_for_service.dart
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
9
lib/src/logger.dart
Normal file
9
lib/src/logger.dart
Normal 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');
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ import 'dart:developer';
|
|||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
import 'package:flutter_openim_sdk/src/logger.dart';
|
||||||
|
|
||||||
class IMManager {
|
class IMManager {
|
||||||
MethodChannel _channel;
|
MethodChannel _channel;
|
||||||
@ -17,6 +18,7 @@ class IMManager {
|
|||||||
late OrganizationManager organizationManager;
|
late OrganizationManager organizationManager;
|
||||||
|
|
||||||
late OnConnectListener _connectListener;
|
late OnConnectListener _connectListener;
|
||||||
|
OnListenerForService? _listenerForService;
|
||||||
late String uid;
|
late String uid;
|
||||||
late UserInfo uInfo;
|
late UserInfo uInfo;
|
||||||
bool isLogined = false;
|
bool isLogined = false;
|
||||||
@ -39,7 +41,7 @@ class IMManager {
|
|||||||
void _addNativeCallback(MethodChannel _channel) {
|
void _addNativeCallback(MethodChannel _channel) {
|
||||||
_channel.setMethodCallHandler((call) {
|
_channel.setMethodCallHandler((call) {
|
||||||
try {
|
try {
|
||||||
log('Flutter : $call');
|
Logger.print('Flutter : $call');
|
||||||
if (call.method == ListenerType.connectListener) {
|
if (call.method == ListenerType.connectListener) {
|
||||||
String type = call.arguments['type'];
|
String type = call.arguments['type'];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -353,9 +355,39 @@ class IMManager {
|
|||||||
messageManager.messageKvInfoListener?.messageKvInfoChanged(list);
|
messageManager.messageKvInfoListener?.messageKvInfoChanged(list);
|
||||||
break;
|
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 (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
log("回调失败了。$error ${call.method} ${call.arguments['type']} ${call.arguments['data']} $stackTrace");
|
Logger.print(
|
||||||
|
"回调失败了。${call.method} ${call.arguments['type']} ${call.arguments['data']} $error $stackTrace");
|
||||||
}
|
}
|
||||||
return Future.value(null);
|
return Future.value(null);
|
||||||
});
|
});
|
||||||
@ -516,6 +548,21 @@ class IMManager {
|
|||||||
'operationID': Utils.checkOperationID(operationID),
|
'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;
|
MethodChannel get channel => _channel;
|
||||||
|
|
||||||
static Map _buildParam(Map param) {
|
static Map _buildParam(Map param) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user