putFile replace to uploadFile
This commit is contained in:
@@ -20,7 +20,7 @@ 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/put_file_listener.dart';
|
||||
export 'src/listener/upload_file_listener.dart';
|
||||
export 'src/listener/user_listener.dart';
|
||||
export 'src/manager/im_conversation_manager.dart';
|
||||
export 'src/manager/im_friendship_manager.dart';
|
||||
|
||||
@@ -14,5 +14,5 @@ class ListenerType {
|
||||
static const customBusinessListener = "customBusinessListener";
|
||||
static const messageKvInfoListener = "messageKvInfoListener";
|
||||
static const listenerForService = "listenerForService";
|
||||
static const putFileListener = "putFileListener";
|
||||
static const uploadFileListener = "uploadFileListener";
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
class OnPutFileListener {
|
||||
Function(String putID, String hash, int total)? onHashComplete;
|
||||
Function(String putID, int current, int total)? onHashProgress;
|
||||
Function(String putID, int size)? onOpen;
|
||||
Function(String putID, int total, int putType)? onPutComplete;
|
||||
Function(String putID, int save, int current, int total)? onPutProgress;
|
||||
Function(String putID, int current, int total)? onPutStart;
|
||||
|
||||
void hashComplete(String putID, String hash, int total) {
|
||||
onHashComplete?.call(putID, hash, total);
|
||||
}
|
||||
|
||||
void hashProgress(String putID, int current, int total) {
|
||||
onHashProgress?.call(putID, current, total);
|
||||
}
|
||||
|
||||
void open(String putID, int size) {
|
||||
onOpen?.call(putID, size);
|
||||
}
|
||||
|
||||
void putComplete(String putID, int total, int putType) {
|
||||
onPutComplete?.call(putID, total, putType);
|
||||
}
|
||||
|
||||
void putProgress(String putID, int save, int current, int total) {
|
||||
onPutProgress?.call(putID, save, current, total);
|
||||
}
|
||||
|
||||
void putStart(String putID, int current, int total) {
|
||||
onPutStart?.call(putID, current, total);
|
||||
}
|
||||
}
|
||||
45
lib/src/listener/upload_file_listener.dart
Normal file
45
lib/src/listener/upload_file_listener.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
class OnUploadFileListener {
|
||||
Function(String id, int size, String url, int type)? onComplete;
|
||||
Function(String id, String partHash, String fileHash)? onHashPartComplete;
|
||||
Function(String id, int index, int size, String partHash)? onHashPartProgress;
|
||||
Function(String id, int size)? onOpen;
|
||||
Function(String id, int partSize, int num)? onPartSize;
|
||||
Function(String id, int fileSize, int streamSize, int storageSize)?
|
||||
onUploadComplete;
|
||||
Function(String id, String uploadID)? onUploadID;
|
||||
Function(String id, int index, int partSize, String partHash)?
|
||||
onUploadPartComplete;
|
||||
|
||||
void complete(String id, int size, String url, int type) {
|
||||
onComplete?.call(id, size, url, type);
|
||||
}
|
||||
|
||||
void hashPartComplete(String id, String partHash, String fileHash) {
|
||||
onHashPartComplete?.call(id, partHash, fileHash);
|
||||
}
|
||||
|
||||
void hashPartProgress(String id, int index, int size, String partHash) {
|
||||
onHashPartProgress?.call(id, index, size, partHash);
|
||||
}
|
||||
|
||||
void open(String id, int size) {
|
||||
onOpen?.call(id, size);
|
||||
}
|
||||
|
||||
void partSize(String id, int partSize, int num) {
|
||||
onPartSize?.call(id, partSize, num);
|
||||
}
|
||||
|
||||
void uploadComplete(
|
||||
String id, int fileSize, int streamSize, int storageSize) {
|
||||
onUploadComplete?.call(id, fileSize, streamSize, storageSize);
|
||||
}
|
||||
|
||||
void uploadID(String id, String uploadID) {
|
||||
onUploadID?.call(id, uploadID);
|
||||
}
|
||||
|
||||
void uploadPartComplete(String id, int index, int partSize, String partHash) {
|
||||
onUploadPartComplete?.call(id, index, partSize, partHash);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_openim_sdk/src/listener/upload_file_listener.dart';
|
||||
import 'package:flutter_openim_sdk/src/logger.dart';
|
||||
|
||||
class IMManager {
|
||||
@@ -15,7 +16,7 @@ class IMManager {
|
||||
|
||||
late OnConnectListener _connectListener;
|
||||
OnListenerForService? _listenerForService;
|
||||
OnPutFileListener? _putFileListener;
|
||||
OnUploadFileListener? _uploadFileListener;
|
||||
late String userID;
|
||||
late UserInfo userInfo;
|
||||
bool isLogined = false;
|
||||
@@ -316,45 +317,61 @@ class IMManager {
|
||||
_listenerForService?.recvNewMessage(msg);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.putFileListener) {
|
||||
} else if (call.method == ListenerType.uploadFileListener) {
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'hashComplete':
|
||||
String putID = data['putID'];
|
||||
String hash = data['hash'];
|
||||
int total = data['total'];
|
||||
_putFileListener?.hashComplete(putID, hash, total);
|
||||
case 'complete':
|
||||
String id = data['id'];
|
||||
int size = data['size'];
|
||||
String url = data['url'];
|
||||
int type = data['type'];
|
||||
_uploadFileListener?.complete(id, size, url, type);
|
||||
break;
|
||||
case 'hashProgress':
|
||||
String putID = data['putID'];
|
||||
int current = data['current'];
|
||||
int total = data['total'];
|
||||
_putFileListener?.hashProgress(putID, current, total);
|
||||
case 'hashPartComplete':
|
||||
String id = data['id'];
|
||||
String partHash = data['partHash'];
|
||||
String fileHash = data['fileHash'];
|
||||
_uploadFileListener?.hashPartComplete(id, partHash, fileHash);
|
||||
break;
|
||||
case 'hashPartProgress':
|
||||
String id = data['id'];
|
||||
int index = data['index'];
|
||||
int size = data['size'];
|
||||
String partHash = data['partHash'];
|
||||
_uploadFileListener?.hashPartProgress(id, index, size, partHash);
|
||||
break;
|
||||
case 'open':
|
||||
String putID = data['putID'];
|
||||
String id = data['id'];
|
||||
int size = data['size'];
|
||||
_putFileListener?.open(putID, size);
|
||||
_uploadFileListener?.open(id, size);
|
||||
break;
|
||||
case 'putComplete':
|
||||
String putID = data['putID'];
|
||||
int putType = data['putType'];
|
||||
int total = data['total'];
|
||||
_putFileListener?.putComplete(putID, putType, total);
|
||||
case 'partSize':
|
||||
String id = data['id'];
|
||||
int partSize = data['partSize'];
|
||||
int num = data['num'];
|
||||
_uploadFileListener?.partSize(id, partSize, num);
|
||||
break;
|
||||
case 'putProgress':
|
||||
String putID = data['putID'];
|
||||
int save = data['save'];
|
||||
int current = data['current'];
|
||||
int total = data['total'];
|
||||
_putFileListener?.putProgress(putID, save, current, total);
|
||||
case 'uploadComplete':
|
||||
String id = data['id'];
|
||||
int fileSize = data['fileSize'];
|
||||
int streamSize = data['streamSize'];
|
||||
int storageSize = data['storageSize'];
|
||||
_uploadFileListener?.uploadComplete(
|
||||
id, fileSize, streamSize, storageSize);
|
||||
break;
|
||||
case 'putStart':
|
||||
String putID = data['putID'];
|
||||
int current = data['current'];
|
||||
int total = data['total'];
|
||||
_putFileListener?.putStart(putID, current, total);
|
||||
case 'uploadID':
|
||||
String id = data['id'];
|
||||
String uploadID = data['uploadID'];
|
||||
_uploadFileListener?.uploadID(id, uploadID);
|
||||
break;
|
||||
case 'uploadPartComplete':
|
||||
String id = data['id'];
|
||||
int index = data['index'];
|
||||
int partSize = data['partSize'];
|
||||
String partHash = data['partHash'];
|
||||
_uploadFileListener?.uploadPartComplete(
|
||||
id, index, partSize, partHash);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -485,18 +502,22 @@ class IMManager {
|
||||
Future<UserInfo> getLoginUserInfo() async => userInfo;
|
||||
|
||||
///
|
||||
Future putFile({
|
||||
required String putID,
|
||||
Future uploadFile({
|
||||
required String id,
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
String? contentType,
|
||||
String? cause,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'putFile',
|
||||
'uploadFile',
|
||||
_buildParam({
|
||||
'putID': putID,
|
||||
'id': id,
|
||||
'filePath': filePath,
|
||||
'name': fileName,
|
||||
'contentType': contentType,
|
||||
'cause': cause,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
@@ -535,8 +556,8 @@ class IMManager {
|
||||
// 'operationID': Utils.checkOperationID(operationID),
|
||||
// }));
|
||||
|
||||
void setPutFileListener(OnPutFileListener listener) {
|
||||
_putFileListener = listener;
|
||||
void setUploadFileListener(OnUploadFileListener listener) {
|
||||
_uploadFileListener = listener;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user