如何在iOS应用程序中实现XEP-0333?

时间:2017-10-10 12:51:28

标签: swift xmpp chat ejabberd xmppframework

我正在开发一个聊天应用程序,我需要显示消息状态,如WhatsApp应用程序,我已经尝试过XEP-0333(聊天标记),但面临问题。

1)从其他端获取Received Marker后,XMPPMessage Archive未更新消息,带有Received Marker(在Core数据中,消息聊天标记状态未更新)。

2)如何实现显示的标记逻辑? (表示我们需要发送显示标记的每条消息或一次只能显示一个对话框。)

XEP链接:XEP-0333

代码:

         //(Sender Part)
            let completeMessage = DDXMLElement.element(withName: "message") as! DDXMLElement //(In that i have set id,body,to and type as chat)
            let msgObj = XMPPMessage(from: completeMessage)
            msgObj?.addMarkableChatMarker()
            xmppStream?.send(msgObj)

        //(Receiver Part)
    didReceivedMessage - Method

    //*Check One condition*
    if message.isChatMessageWithBody() && message.isErrorMessage() == false {
       if (message.hasChatMarker() == true){
                 printLog("Message ID\(message.elementID())")
                 let msgElement = XMPPMessageMng.getChatMessageElement(recipient: message.from().bare(), thread: "")
                    let threadElement = DDXMLElement.element(withName: "thread") as! DDXMLElement
                    threadElement.stringValue = "Thread"
                    msgElement.addChild(threadElement)
                    let msgReceived = XMPPMessage(from: msgElement)
                    msgReceived?.addReceivedChatMarker(withID: message.elementID())
                    xmppStream.send(msgReceived)
                }
    }

    else{
          if (message.hasMarkableChatMarker() == true){
               printLog("Chat Marker ID\(message.chatMarkerID())")
             }else if (message.hasReceivedChatMarker() == true){
                  printLog("Chat Marker ID\(message.chatMarkerID())")
             }
    }

//对于展示标记我已做过以下事情。 - 使用JID从消息存档加载消息时。 loadArchivedMessagesFromJID - 方法

//message as XMPPMessageArchiving_Message_CoreDataObject
let msgReceived = XMPPMessage(from: msgElement)
                            msgReceived?.addDisplayedChatMarker(withID: message.message.elementID())
xmppStream.send(msgReceived)

让我知道我们可以通过哪种方式实现聊天标记协议。

开发工具:Xcode 8.3(Swift 3.0), 服务器:ejabberd

1 个答案:

答案 0 :(得分:0)

ejabberd仍然不支持xep-0333

这里是支持XEP的链接:

Protocols Supported by ejabberd