FluuxIO / XMPP

Pure Swift XMPP library
https://www.process-one.net/
Apache License 2.0
45 stars 6 forks source link

App Remaining Functionality Not Working #11

Closed Mahesh160393 closed 3 years ago

Mahesh160393 commented 3 years ago

Hello @mremond

Installed pod 'XMPP' in my project And added the following code in the viewDidAppear().

        guard let jid = JID("JID USER NAME") else {
            print("Invalid JID");
            exit(1)
        }
        var xmppConfig = Config(jid: jid, password: "JID PASSWORD", useTLS: true)
        xmppConfig.allowInsecure = true
        xmppConfig.host = "MY IP ADDRESS"
        xmppConfig.streamObserver = DefaultStreamObserver()

        let client = XMPP(config: xmppConfig)

        let semaphore = DispatchSemaphore(value: 0)
        client.connect {
          print("Disconnected !")
          semaphore.signal()
        }
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)

After this my app remaining functionality not working. Like bottom tab bar. If I removed the following line everything is working fine.

_ = semaphore.wait(timeout: DispatchTime.distantFuture)

Maybe I'm doing something wrong. can you check once.

Thank You

pixelskull commented 3 years ago

Since I am just in a random Browser Session, looking for Alternative xmpp Frameworks, I don’t know the insides but...

You are blocking your UI Thread with the wait Operation. So your app wont finnish the drawing. You should do the connection and waiting in a dispatchqueue other than the ui queue.

Mahesh160393 commented 3 years ago

@pixelskull Thank you reply. This issue is resolved.