@@ -11,7 +11,7 @@ public class IMMananger: BaseServiceManager {
11
11
self [ " login " ] = login
12
12
self [ " logout " ] = logout
13
13
self [ " getLoginStatus " ] = getLoginStatus
14
- self [ " putFile " ] = putFile
14
+ self [ " uploadFile " ] = uploadFile
15
15
self [ " updateFcmToken " ] = updateFcmToken
16
16
self [ " setAppBackgroundStatus " ] = setAppBackgroundStatus
17
17
self [ " networkStatusChanged " ] = networkStatusChanged
@@ -22,7 +22,7 @@ public class IMMananger: BaseServiceManager {
22
22
selector: #selector( applicationWillEnterForeground) ,
23
23
name: UIApplication . willEnterForegroundNotification,
24
24
object: nil )
25
-
25
+
26
26
NotificationCenter . default. addObserver ( self ,
27
27
selector: #selector( applicationDidEnterBackground) ,
28
28
name: UIApplication . didEnterBackgroundNotification,
@@ -51,7 +51,7 @@ public class IMMananger: BaseServiceManager {
51
51
Open_im_sdkSetAppBackgroundStatus ( BaseCallback ( result: { _ in
52
52
} ) , UUID ( ) . uuidString, true )
53
53
}
54
-
54
+
55
55
@objc
56
56
fileprivate func applicationWillEnterForeground( ) {
57
57
Open_im_sdkSetAppBackgroundStatus ( BaseCallback ( result: { _ in
@@ -75,8 +75,8 @@ public class IMMananger: BaseServiceManager {
75
75
callBack ( result, Open_im_sdkGetLoginStatus ( methodCall [ string: " operationID " ] ) )
76
76
}
77
77
78
- func putFile ( methodCall: FlutterMethodCall , result: @escaping FlutterResult ) {
79
- Open_im_sdkPutFile ( BaseCallback ( result: result) , methodCall [ string: " operationID " ] , methodCall. toJsonString ( ) , PutFileListener ( channel: self . channel, putID : methodCall [ string: " putID " ] ) )
78
+ func uploadFile ( methodCall: FlutterMethodCall , result: @escaping FlutterResult ) {
79
+ Open_im_sdkUploadFile ( BaseCallback ( result: result) , methodCall [ string: " operationID " ] , methodCall. toJsonString ( ) , UploadFileListener ( channel: self . channel, id : methodCall [ string: " id " ] ) )
80
80
}
81
81
82
82
func updateFcmToken( methodCall: FlutterMethodCall , result: @escaping FlutterResult ) {
@@ -102,7 +102,7 @@ public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol
102
102
public func onConnectFailed( _ errCode: Int32 , errMsg: String ? ) {
103
103
CommonUtil . emitEvent ( channel: self . channel, method: " connectListener " , type: " onConnectFailed " , errCode: errCode, errMsg: errMsg, data: nil )
104
104
}
105
-
105
+
106
106
public func onConnectSuccess( ) {
107
107
CommonUtil . emitEvent ( channel: self . channel, method: " connectListener " , type: " onConnectSuccess " , errCode: nil , errMsg: nil , data: nil )
108
108
}
@@ -120,60 +120,79 @@ public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol
120
120
}
121
121
}
122
122
123
- public class PutFileListener : NSObject , Open_im_sdk_callbackPutFileCallbackProtocol {
123
+ public class UploadFileListener : NSObject , Open_im_sdk_callbackUploadFileCallbackProtocol {
124
+
124
125
private let channel : FlutterMethodChannel
125
- private let putID : String
126
+ private let id : String
126
127
127
- init ( channel: FlutterMethodChannel , putID : String ) {
128
+ init ( channel: FlutterMethodChannel , id : String ) {
128
129
self . channel = channel
129
- self . putID = putID
130
+ self . id = id
131
+ }
132
+
133
+ public func complete( _ size: Int64 , url: String ? , typ: Int32 ) {
134
+ var values : [ String : Any ] = [ : ]
135
+ values [ " id " ] = id
136
+ values [ " size " ] = size
137
+ values [ " url " ] = url
138
+ values [ " type " ] = typ
139
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " complete " , errCode: nil , errMsg: nil , data: values)
130
140
}
131
141
132
- public func hashComplete ( _ hash : String ? , total : Int64 ) {
142
+ public func hashPartComplete ( _ partsHash : String ? , fileHash : String ? ) {
133
143
var values : [ String : Any ] = [ : ]
134
- values [ " putID " ] = putID
135
- values [ " hash " ] = hash
136
- values [ " total " ] = total
137
- CommonUtil . emitEvent ( channel: channel, method: " putFileListener " , type: " hashComplete " , errCode: nil , errMsg: nil , data: values)
144
+ values [ " id " ] = id
145
+ values [ " partHash " ] = partsHash
146
+ values [ " fileHash " ] = fileHash
147
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " hashPartComplete " , errCode: nil , errMsg: nil , data: values) ; < #code# >
138
148
}
139
149
140
- public func hashProgress ( _ current : Int64 , total : Int64 ) {
150
+ public func hashPartProgress ( _ index : Int32 , size : Int64 , partHash : String ? ) {
141
151
var values : [ String : Any ] = [ : ]
142
- values [ " putID " ] = putID
143
- values [ " current " ] = current
144
- values [ " total " ] = total
145
- CommonUtil . emitEvent ( channel: channel, method: " putFileListener " , type: " hashProgress " , errCode: nil , errMsg: nil , data: values)
152
+ values [ " id " ] = id
153
+ values [ " index " ] = index
154
+ values [ " size " ] = size
155
+ values [ " partHash " ] = partHash
156
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " hashPartProgress " , errCode: nil , errMsg: nil , data: values)
146
157
}
147
158
148
159
public func open( _ size: Int64 ) {
149
160
var values : [ String : Any ] = [ : ]
150
- values [ " putID " ] = putID
161
+ values [ " id " ] = id
151
162
values [ " size " ] = size
152
- CommonUtil . emitEvent ( channel: channel, method: " putFileListener " , type: " open " , errCode: nil , errMsg: nil , data: values)
163
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " open " , errCode: nil , errMsg: nil , data: values)
164
+ }
165
+
166
+ public func partSize( _ partSize: Int64 , num: Int32 ) {
167
+ var values : [ String : Any ] = [ : ]
168
+ values [ " id " ] = id
169
+ values [ " partSize " ] = partSize
170
+ values [ " num " ] = num
171
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " partSize " , errCode: nil , errMsg: nil , data: values)
153
172
}
154
173
155
- public func putComplete ( _ total : Int64 , putType : Int ) {
174
+ public func uploadComplete ( _ fileSize : Int64 , streamSize : Int64 , storageSize : Int64 ) {
156
175
var values : [ String : Any ] = [ : ]
157
- values [ " putID " ] = putID
158
- values [ " putType " ] = putType
159
- values [ " total " ] = total
160
- CommonUtil . emitEvent ( channel: channel, method: " putFileListener " , type: " putComplete " , errCode: nil , errMsg: nil , data: values)
176
+ values [ " id " ] = id
177
+ values [ " fileSize " ] = fileSize
178
+ values [ " streamSize " ] = streamSize
179
+ values [ " storageSize " ] = storageSize
180
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " uploadProgress " , errCode: nil , errMsg: nil , data: values)
161
181
}
162
182
163
- public func putProgress ( _ save : Int64 , current : Int64 , total : Int64 ) {
183
+ public func uploadID ( _ uploadID : String ? ) {
164
184
var values : [ String : Any ] = [ : ]
165
- values [ " putID " ] = putID
166
- values [ " save " ] = save
167
- values [ " current " ] = current
168
- values [ " total " ] = total
169
- CommonUtil . emitEvent ( channel: channel, method: " putFileListener " , type: " putProgress " , errCode: nil , errMsg: nil , data: values)
185
+ values [ " id " ] = id
186
+ values [ " uploadID " ] = uploadID
187
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " uploadID " , errCode: nil , errMsg: nil , data: values)
170
188
}
171
189
172
- public func putStart ( _ current : Int64 , total : Int64 ) {
190
+ public func uploadPartComplete ( _ index : Int32 , partSize : Int64 , partHash : String ? ) {
173
191
var values : [ String : Any ] = [ : ]
174
- values [ " putID " ] = putID
175
- values [ " current " ] = current
176
- values [ " total " ] = total
177
- CommonUtil . emitEvent ( channel: channel, method: " putFileListener " , type: " putStart " , errCode: nil , errMsg: nil , data: values)
192
+ values [ " id " ] = id
193
+ values [ " index " ] = index
194
+ values [ " partSize " ] = partSize
195
+ values [ " partHash " ] = partHash
196
+ CommonUtil . emitEvent ( channel: channel, method: " uploadFileListener " , type: " uploadPartComplete " , errCode: nil , errMsg: nil , data: values) ;< #code#>
178
197
}
179
198
}
0 commit comments