feat: Add the log upload function of SDK.
This commit is contained in:
parent
92dd3adad5
commit
2e94254192
@ -0,0 +1,26 @@
|
|||||||
|
package io.openim.flutter_openim_sdk.listener;
|
||||||
|
|
||||||
|
import android.util.ArrayMap;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.flutter.plugin.common.MethodCall;
|
||||||
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
|
import io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||||
|
import open_im_sdk_callback.UploadLogProgress;
|
||||||
|
|
||||||
|
public class OnUploadLogsListener implements UploadLogProgress {
|
||||||
|
final private MethodChannel.Result result;
|
||||||
|
|
||||||
|
public OnUploadLogsListener(MethodChannel.Result result, MethodCall call) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProgress(long current, long size) {
|
||||||
|
final Map<String, Object> values = new ArrayMap<>();
|
||||||
|
values.put("current", current);
|
||||||
|
values.put("size", size);
|
||||||
|
CommonUtil.emitEvent("uploadLogsListener", "onProgress", values);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin;
|
|||||||
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.OnUploadFileListener;
|
import io.openim.flutter_openim_sdk.listener.OnUploadFileListener;
|
||||||
|
import io.openim.flutter_openim_sdk.listener.OnUploadLogsListener;
|
||||||
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;
|
||||||
|
|
||||||
@ -62,6 +63,13 @@ public class IMManager extends BaseManager {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void uploadLogs(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
|
Open_im_sdk.uploadLogs(
|
||||||
|
new OnBaseListener(result, methodCall),
|
||||||
|
value(methodCall, "operationID"),
|
||||||
|
new OnUploadLogsListener(result, methodCall)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void setAppBackgroundStatus(MethodCall methodCall, MethodChannel.Result result) {
|
public void setAppBackgroundStatus(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.setAppBackgroundStatus(
|
Open_im_sdk.setAppBackgroundStatus(
|
||||||
|
@ -13,6 +13,7 @@ public class IMMananger: BaseServiceManager {
|
|||||||
self["logout"] = logout
|
self["logout"] = logout
|
||||||
self["getLoginStatus"] = getLoginStatus
|
self["getLoginStatus"] = getLoginStatus
|
||||||
self["uploadFile"] = uploadFile
|
self["uploadFile"] = uploadFile
|
||||||
|
self["uploadLogs"] = uploadLogs
|
||||||
self["updateFcmToken"] = updateFcmToken
|
self["updateFcmToken"] = updateFcmToken
|
||||||
self["setAppBackgroundStatus"] = setAppBackgroundStatus
|
self["setAppBackgroundStatus"] = setAppBackgroundStatus
|
||||||
self["networkStatusChanged"] = networkStatusChanged
|
self["networkStatusChanged"] = networkStatusChanged
|
||||||
@ -84,6 +85,10 @@ public class IMMananger: BaseServiceManager {
|
|||||||
Open_im_sdkUploadFile(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString(), UploadFileListener(channel: self.channel,id: methodCall[string: "id"]))
|
Open_im_sdkUploadFile(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString(), UploadFileListener(channel: self.channel,id: methodCall[string: "id"]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uploadLogs(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
|
Open_im_sdkUploadLogs(BaseCallback(result: result), methodCall[string: "operationID"], UploadLogsListener(channel: self.channel))
|
||||||
|
}
|
||||||
|
|
||||||
func updateFcmToken(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
func updateFcmToken(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||||
Open_im_sdkUpdateFcmToken(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "fcmToken"], methodCall[int64:
|
Open_im_sdkUpdateFcmToken(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "fcmToken"], methodCall[int64:
|
||||||
"expireTime"])
|
"expireTime"])
|
||||||
@ -126,6 +131,23 @@ public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class UploadLogsListener: NSObject, Open_im_sdk_callbackUploadLogProgressProtocol {
|
||||||
|
|
||||||
|
private let channel:FlutterMethodChannel
|
||||||
|
|
||||||
|
init(channel:FlutterMethodChannel) {
|
||||||
|
self.channel = channel
|
||||||
|
}
|
||||||
|
|
||||||
|
public func onProgress(_ current: Int64, size: Int64) {
|
||||||
|
var values: [String: Any] = [:]
|
||||||
|
values["current"] = current
|
||||||
|
values["size"] = size
|
||||||
|
CommonUtil.emitEvent(channel: channel, method: "uploadLogsListener", type: "onProgress", errCode: nil, errMsg: nil, data: values)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class UploadFileListener: NSObject, Open_im_sdk_callbackUploadFileCallbackProtocol {
|
public class UploadFileListener: NSObject, Open_im_sdk_callbackUploadFileCallbackProtocol {
|
||||||
|
|
||||||
private let channel:FlutterMethodChannel
|
private let channel:FlutterMethodChannel
|
||||||
|
@ -15,4 +15,5 @@ class ListenerType {
|
|||||||
static const messageKvInfoListener = "messageKvInfoListener";
|
static const messageKvInfoListener = "messageKvInfoListener";
|
||||||
static const listenerForService = "listenerForService";
|
static const listenerForService = "listenerForService";
|
||||||
static const uploadFileListener = "uploadFileListener";
|
static const uploadFileListener = "uploadFileListener";
|
||||||
|
static const uploadLogsListener = "uploadLogsListener";
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
class OnUploadLogsListener {
|
||||||
|
Function(int current, int size)? onUploadProgress;
|
||||||
|
OnUploadLogsListener({this.onUploadProgress});
|
||||||
|
|
||||||
|
void onProgress(int current, int size) {
|
||||||
|
onUploadProgress?.call(current, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class OnUploadFileListener {
|
class OnUploadFileListener {
|
||||||
Function(String id, int size, String url, int type)? onComplete;
|
Function(String id, int size, String url, int type)? onComplete;
|
||||||
Function(String id, String partHash, String fileHash)? onHashPartComplete;
|
Function(String id, String partHash, String fileHash)? onHashPartComplete;
|
||||||
|
@ -16,6 +16,8 @@ class IMManager {
|
|||||||
late OnConnectListener _connectListener;
|
late OnConnectListener _connectListener;
|
||||||
OnListenerForService? _listenerForService;
|
OnListenerForService? _listenerForService;
|
||||||
OnUploadFileListener? _uploadFileListener;
|
OnUploadFileListener? _uploadFileListener;
|
||||||
|
OnUploadLogsListener? _uploadLogsListener;
|
||||||
|
|
||||||
late String userID;
|
late String userID;
|
||||||
late UserInfo userInfo;
|
late UserInfo userInfo;
|
||||||
bool isLogined = false;
|
bool isLogined = false;
|
||||||
@ -273,6 +275,15 @@ class IMManager {
|
|||||||
_listenerForService?.recvNewMessage(msg);
|
_listenerForService?.recvNewMessage(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (call.method == ListenerType.uploadLogsListener) {
|
||||||
|
String type = call.arguments['type'];
|
||||||
|
dynamic data = call.arguments['data'];
|
||||||
|
switch (type) {
|
||||||
|
case 'onProgress':
|
||||||
|
int size = data['size'];
|
||||||
|
int current = data['current'];
|
||||||
|
_uploadLogsListener?.onProgress(current, size);
|
||||||
|
}
|
||||||
} else if (call.method == ListenerType.uploadFileListener) {
|
} else if (call.method == ListenerType.uploadFileListener) {
|
||||||
String type = call.arguments['type'];
|
String type = call.arguments['type'];
|
||||||
dynamic data = call.arguments['data'];
|
dynamic data = call.arguments['data'];
|
||||||
@ -511,6 +522,21 @@ class IMManager {
|
|||||||
'operationID': Utils.checkOperationID(operationID),
|
'operationID': Utils.checkOperationID(operationID),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
/// 上传日志
|
||||||
|
/// [uploadlogParams] system_type、ex
|
||||||
|
Future uploadLogs({
|
||||||
|
String? operationID,
|
||||||
|
}) =>
|
||||||
|
_channel.invokeMethod(
|
||||||
|
'uploadLogs',
|
||||||
|
_buildParam({
|
||||||
|
'operationID': Utils.checkOperationID(operationID),
|
||||||
|
}));
|
||||||
|
|
||||||
|
void setUploadLogsListener(OnUploadLogsListener listener) {
|
||||||
|
_uploadLogsListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
void setUploadFileListener(OnUploadFileListener listener) {
|
void setUploadFileListener(OnUploadFileListener listener) {
|
||||||
_uploadFileListener = listener;
|
_uploadFileListener = listener;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user