|
@@ -81,8 +81,11 @@ UNI_EXPORT_METHOD_SYNC(@selector(connect:userId:token:))
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onChannelInfoUpdated:) name:kChannelInfoUpdated object:nil];
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUserOnlineStateUpdated:) name:kUserOnlineStateUpdated object:nil];
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaUploadProgress:) name:kUploadMediaMessageProgresse object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMessageStatusUpdated:) name:kSendingMessageStatusUpdated object:nil];
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMessageUpdated:) name:kMessageUpdated object:nil];
|
|
|
+
|
|
|
return [[WFCCNetworkService sharedInstance] connect:userId token:token];
|
|
|
}
|
|
|
//
|
|
@@ -2357,6 +2360,40 @@ UNI_EXPORT_METHOD(@selector(createChannel:portrait:desc:extra:success:error:))
|
|
|
[self onIndication:@[@"onUserOnlineStateUpdated", [self convertModelListToString:events]]];
|
|
|
}
|
|
|
|
|
|
+- (void)onMediaUploadProgress:(NSNotification *)notification {
|
|
|
+ WFCCMessage *msg = notification.userInfo[@"message"];
|
|
|
+ BOOL finish = [notification.userInfo[@"finish"] boolValue];
|
|
|
+ if(finish) {
|
|
|
+ NSString *remoteUrl = notification.userInfo[@"remoteUrl"];
|
|
|
+ [self onIndication:@[@"onMediaUpload", msg.toJsonStr, remoteUrl]];
|
|
|
+ } else {
|
|
|
+ int uploaded = [notification.userInfo[@"uploaded"] intValue];
|
|
|
+ int total = [notification.userInfo[@"total"] intValue];
|
|
|
+ [self onIndication:@[@"onProgress", msg.toJsonStr, @(uploaded), @(total)]];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)onMessageStatusUpdated:(NSNotification *)notification {
|
|
|
+ int status = [notification.userInfo[@"status"] intValue];
|
|
|
+ WFCCMessage *msg = notification.userInfo[@"message"];
|
|
|
+
|
|
|
+ if(status == Message_Status_Sent) {
|
|
|
+ [self onIndication:@[@"onSendSuccess", msg.toJsonStr]];
|
|
|
+ } else if(status == Message_Status_Send_Failure) {
|
|
|
+ int errorCode = [notification.userInfo[@"errorCode"] intValue];
|
|
|
+ [self onIndication:@[@"onSendFail", msg.toJsonStr, @(errorCode)]];
|
|
|
+ } else if(status == Message_Status_Sending) {
|
|
|
+ int64_t saveTime = [notification.userInfo[@"saveTime"] longLongValue];
|
|
|
+ [self onIndication:@[@"onSendPrepare", msg.toJsonStr, @(saveTime)]];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)onMessageUpdated:(NSNotification *)notification {
|
|
|
+ long messageId = [notification.object longValue];
|
|
|
+ WFCCMessage *msg = [[WFCCIMService sharedWFCIMService] getMessage:messageId];
|
|
|
+ [self onIndication:@[@"onMessageUpdate", msg.toJsonStr]];
|
|
|
+}
|
|
|
+
|
|
|
- (WFCCConversation *)conversationFromJsonString:(NSString *)strConv {
|
|
|
NSError *__error = nil;
|
|
|
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[strConv dataUsingEncoding:NSUTF8StringEncoding]
|