@@ -2202,36 +2202,42 @@ extension IMClient {
22022202
22032203 func process( rcpCommand: IMRcpCommand , serverTimestamp: Int64 ? ) {
22042204 assert ( self . specificAssertion)
2205- guard let conversationID: String = ( rcpCommand. hasCid ? rcpCommand. cid : nil ) else {
2205+ guard let conversationID = ( rcpCommand. hasCid ? rcpCommand. cid : nil ) else {
22062206 return
22072207 }
22082208 self . getConversation ( by: conversationID) { ( client, result) in
22092209 assert ( client. specificAssertion)
22102210 switch result {
22112211 case . success( value: let conversation) :
2212- guard
2213- let messageID: String = ( rcpCommand. hasID ? rcpCommand. id : nil ) ,
2214- let timestamp: Int64 = ( rcpCommand. hasT ? rcpCommand. t : nil )
2215- else
2216- { return }
2212+ guard let messageID = ( rcpCommand. hasID ? rcpCommand. id : nil ) ,
2213+ let timestamp = ( rcpCommand. hasT ? rcpCommand. t : nil ) else {
2214+ return
2215+ }
22172216 let fromID = ( rcpCommand. hasFrom ? rcpCommand. from : nil )
2218- let event : IMMessageEvent
2219- if rcpCommand. hasRead, rcpCommand. read {
2220- event = . read(
2217+ let isRead = ( rcpCommand. hasRead ? rcpCommand. read : false )
2218+ let messageEvent : IMMessageEvent
2219+ if isRead {
2220+ messageEvent = . read(
22212221 byClientID: fromID,
22222222 messageID: messageID,
2223- readTimestamp: timestamp
2224- )
2223+ readTimestamp: timestamp)
22252224 } else {
2226- event = . delivered(
2225+ messageEvent = . delivered(
22272226 toClientID: fromID,
22282227 messageID: messageID,
2229- deliveredTimestamp: timestamp
2230- )
2228+ deliveredTimestamp: timestamp)
22312229 }
2232- client. localRecord. update ( lastServerTimestamp: serverTimestamp)
2230+ client. localRecord. update (
2231+ lastServerTimestamp: serverTimestamp)
2232+ conversation. process (
2233+ rcpTimestamp: timestamp,
2234+ isRead: isRead,
2235+ client: client)
22332236 client. eventQueue. async {
2234- client. delegate? . client ( client, conversation: conversation, event: . message( event: event) )
2237+ client. delegate? . client (
2238+ client, conversation: conversation,
2239+ event: . message(
2240+ event: messageEvent) )
22352241 }
22362242 case . failure( error: let error) :
22372243 Logger . shared. error ( error)
@@ -2514,104 +2520,86 @@ extension IMClient: RTMConnectionDelegate {
25142520// MARK: - Event
25152521
25162522/// The session event about the client.
2517- ///
2518- /// - sessionDidOpen: Session opened event.
2519- /// - sessionDidResume: Session in resuming event.
2520- /// - sessionDidPause: Session paused event.
2521- /// - sessionDidClose: Session closed event.
25222523public enum IMClientEvent {
2523-
2524+ /// Session opened event.
25242525 case sessionDidOpen
2525-
2526+ /// Session in resuming event.
25262527 case sessionDidResume
2527-
2528+ /// Session paused event.
25282529 case sessionDidPause( error: LCError )
2529-
2530+ /// Session closed event.
25302531 case sessionDidClose( error: LCError )
25312532}
25322533
2533- /// The event about the conversation that belong to the client.
2534- ///
2535- /// - joined: The client joined the conversation.
2536- /// - left: The client left the conversation.
2537- /// - membersJoined: The members joined the conversation.
2538- /// - membersLeft: The members left the conversation.
2539- /// - memberInfoChanged: The info of the member in the conversaiton has changed.
2540- /// - blocked: The client has been blocked in the conversation.
2541- /// - unblocked: The client has been unblocked int the conversation.
2542- /// - membersBlocked: The members have been blocked in the conversation.
2543- /// - membersUnblocked: The members have been unblocked in the conversation.
2544- /// - muted: The client has been muted in the conversation.
2545- /// - unmuted: The client has been unmuted in the conversation.
2546- /// - membersMuted: The members have been muted in the conversation.
2547- /// - membersUnmuted: The members have been unmuted in the conversation.
2548- /// - dataUpdated: The data of the conversation updated.
2549- /// - lastMessageUpdated: The last message of the conversation updated.
2550- /// - unreadMessageCountUpdated: The unread message count of the conversation updated.
2551- /// - message: Events about message in the conversation.
2534+ /// The events about conversation that belong to the client.
25522535public enum IMConversationEvent {
2553-
2536+ /// This client joined this conversation.
25542537 case joined( byClientID: String ? , at: Date ? )
2538+ /// This client left this conversation.
25552539 case left( byClientID: String ? , at: Date ? )
2540+ /// The members joined this conversation.
25562541 case membersJoined( members: [ String ] , byClientID: String ? , at: Date ? )
2542+ /// The members left this conversation.
25572543 case membersLeft( members: [ String ] , byClientID: String ? , at: Date ? )
2558-
2544+ /// The info of the member in this conversaiton has been changed.
25592545 case memberInfoChanged( info: IMConversation . MemberInfo , byClientID: String ? , at: Date ? )
2560-
2546+ /// The client in this conversation has been blocked.
25612547 case blocked( byClientID: String ? , at: Date ? )
2548+ /// The client int this conversation has been unblocked.
25622549 case unblocked( byClientID: String ? , at: Date ? )
2550+ /// The members in this conversation have been blocked.
25632551 case membersBlocked( members: [ String ] , byClientID: String ? , at: Date ? )
2552+ /// The members in this conversation have been unblocked.
25642553 case membersUnblocked( members: [ String ] , byClientID: String ? , at: Date ? )
2565-
2554+ /// The client in this conversation has been muted.
25662555 case muted( byClientID: String ? , at: Date ? )
2556+ /// The client in this conversation has been unmuted.
25672557 case unmuted( byClientID: String ? , at: Date ? )
2558+ /// The members in this conversation have been muted.
25682559 case membersMuted( members: [ String ] , byClientID: String ? , at: Date ? )
2560+ /// The members in this conversation have been unmuted.
25692561 case membersUnmuted( members: [ String ] , byClientID: String ? , at: Date ? )
2570-
2562+ /// The data of this conversation has been updated.
25712563 case dataUpdated( updatingData: [ String : Any ] ? , updatedData: [ String : Any ] ? , byClientID: String ? , at: Date ? )
2572-
2564+ /// The last message of this conversation has been updated, if *newMessage* is *false*, means the message has been modified.
25732565 case lastMessageUpdated( newMessage: Bool )
2574-
2566+ /// The last delivered time of message to other in this conversation has been updated.
2567+ case lastDeliveredAtUpdated
2568+ /// The last read time of message by other in this conversation has been updated.
2569+ case lastReadAtUpdated
2570+ /// The unread message count for this client in this conversation has been updated.
25752571 case unreadMessageCountUpdated
2576-
2572+ /// The events about message that belong to this conversation, @see `IMMessageEvent`.
25772573 case message( event: IMMessageEvent )
25782574}
25792575
2580- /// The event about the message that belong to the conversation.
2581- ///
2582- /// - received: The client received message from the conversation.
2583- /// - updated: The message in the conversation has been updated.
2584- /// - delivered: The message sent to the conversation by the client has delivered to other.
2585- /// - read: The message sent to the conversation by the client has been read by other.
2576+ /// The events about message that belong to the conversation.
25862577public enum IMMessageEvent {
2587-
2578+ /// The new message received from this conversation.
25882579 case received( message: IMMessage )
2589-
2580+ /// The message in this conversation has been updated.
25902581 case updated( updatedMessage: IMMessage , reason: IMMessage . PatchedReason ? )
2591-
2582+ /// The message has been delivered to other.
25922583 case delivered( toClientID: String ? , messageID: String , deliveredTimestamp: Int64 )
2593-
2584+ /// The message sent to other has been read.
25942585 case read( byClientID: String ? , messageID: String , readTimestamp: Int64 )
25952586}
25962587
25972588/// IM Client Delegate
25982589public protocol IMClientDelegate : class {
25992590
26002591 /// Delegate function of the event about the client.
2601- ///
26022592 /// - Parameters:
2603- /// - client: Which the event belong to.
2604- /// - event: @see `IMClientEvent`
2593+ /// - client: Which the * event* belong to.
2594+ /// - event: Belong to the *client*, @see `IMClientEvent`.
26052595 func client( _ client: IMClient , event: IMClientEvent )
26062596
26072597 /// Delegate function of the event about the conversation.
2608- ///
26092598 /// - Parameters:
2610- /// - client: Which the conversation belong to.
2611- /// - conversation: Which the event belong to.
2612- /// - event: @see `IMConversationEvent`
2599+ /// - client: Which the * conversation* belong to.
2600+ /// - conversation: Which the * event* belong to.
2601+ /// - event: Belong to the *conversation*, @see `IMConversationEvent`.
26132602 func client( _ client: IMClient , conversation: IMConversation , event: IMConversationEvent )
2614-
26152603}
26162604
26172605// MARK: - Signature
@@ -2626,7 +2614,6 @@ public protocol IMSignatureDelegate: class {
26262614 /// - action: @see `IMSignature.Action`.
26272615 /// - signatureHandler: The handler for the signature.
26282616 func client( _ client: IMClient , action: IMSignature . Action , signatureHandler: @escaping ( IMClient , IMSignature ? ) -> Void )
2629-
26302617}
26312618
26322619public struct IMSignature {
0 commit comments