123456789101112131415161718192021222324252627282930313233343536 |
- //
- // MUCManager.swift
- // Chat (iOS)
- //
- // Created by Sergey Tarasov on 17.08.2022.
- //
- import Foundation
- import XMPPFramework
- import XMPPFrameworkSwift
- class MUCManager: NSObject {
- var muc: XMPPMUCLight
- var rooms: [Room] = []
- override init() {
- self.muc = XMPPMUCLight()
- super.init()
- self.muc.activate(StreamManager.shared.stream)
- self.muc.addDelegate(self, delegateQueue: .main)
- }
- func fetchRooms() {
- _ = self.muc.discoverRooms(forServiceNamed: "chat.msg.sharix-app.org")
- }
- }
- extension MUCManager: XMPPMUCLightDelegate {
- func xmppMUCLight(_ sender: XMPPMUCLight, didDiscoverRooms rooms: [DDXMLElement], forServiceNamed serviceName: String) {
- debugPrint(rooms)
- self.rooms = rooms.map({ Room(jidString: $0.attributeStringValue(forName: "jid") ?? "", name: $0.attributeStringValue(forName: "name") ?? "") })
- }
- }
|