【问题标题】:When i terminate app MUC group chat members are getting removed当我终止应用程序 MUC 群聊成员被删除
【发布时间】:2022-01-03 11:46:08
【问题描述】:

当我终止应用程序 MUC 群聊成员被删除时,我必须在从书签返回应用程序时再次加入他们吗?我们不想一次又一次地重新加入。有人可以建议如何避免重新加入。

在 Android smack 中有自动重新加入的规定。

即使来自 Openfire 后端,我们也有不可删除的托管代码。

Android 运行正常,iOS 正在删除用户。

请提出建议。

【问题讨论】:

    标签: ios xmpp ejabberd openfire xmppframework


    【解决方案1】:

    不要每次都重新加入房间,而是在用户重新启动应用时设置群组的存在。

    使用以下代码函数设置存在,遍历所有组名并设置存在:

        for group in chatListModel ?? []{            
                if(group.opponent_type == "2"){
                    print("Group Name: \(group.opponent_uuid ?? "")")                
    XMPPGlobal.sharedIntanceXMPP.xmppController.updatePresence(roomJID: XMPPJID(string: "\(group.opponent_uuid ?? "")@\(groupServerName)"))
                }
            }
    

    在您的 XMPPController 类中定义以下函数:

    func updatePresence(roomJID : XMPPJID?) {
                            
            let presence = XMPPPresence(type: "presence")
            presence.addAttribute(withName: "from", stringValue: self.xmppStream.myJID?.user ?? "")
            presence.addAttribute(withName: "to", stringValue: "\(roomJID?.full ?? "")/\(self.xmppStream.myJID?.user ?? "")")
            
            let element = DDXMLElement.init(name: "x", xmlns: XMPPMUCNamespace)
            presence.addChild(element)
            self.xmppStream.send(presence)
            
        }
    

    希望它对你有用。

    【讨论】:

      猜你喜欢
      • 2013-10-16
      • 1970-01-01
      • 2014-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      相关资源
      最近更新 更多