Why XMPP function returns nothing?

Orkhan Alizade

I found in the documentation this:

<iq type='get' id='2'>
    <query xmlns='jabber:iq:roster'/>
</iq>

And write it in Swift as:

public class func getGroups() {
    var xmppStream: XMPPStream?

    let iq: DDXMLElement = DDXMLElement.elementWithName("iq") as! DDXMLElement
    iq.addAttributeWithName("type", stringValue: "get")
    iq.addAttributeWithName("id", stringValue: "2")

    let query: DDXMLElement = DDXMLElement(name: "query", xmlns: "jabber:iq:roster") as! DDXMLElement
    iq.addChild(query)

    xmppStream?.sendElement(iq)
}

And when I run it from my ViewController as:

override func viewDidLoad(animated: Bool) {
    print("Group list: \(getGroups())")
}

it returns me empty value, just Group list:.

My question is, how can I run my function properly and get the result, because when I run my XMPP <iq> snippet in my server, it returns me value.

UPDATE You can write or correct my code even in Objective C

UPDATE

extension OneRoster: XMPPStreamDelegate {
    public func xmppStream(sender: XMPPStream, didReceiveIQ ip: XMPPIQ) -> Bool {
        return false
    }
}
vitalyster

You are trying to reinvent XMPPRoster module bundled with XMPPFramework: just instantiate it and activate on your XMPPStream instance and it will automatically sync your roster and groups. iPhoneXMPP example show you roster with groups backed up by this module.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

if function in javascript returns nothing..why?

python function returns nothing

Return function returns nothing

Why Nothing == (pure Nothing) returns False in Haskell?

How to create function that returns nothing

Laravel hasmany function returns nothing

Why this function return nothing?

Function that only returns false returns nothing

Why can't I annotate a function expression as void despite that it returns nothing in TypeScript?

Why won’t C compiler give a warning when writing a function which returns nothing and has no side effect?

Ajax request returns nothing. why?

Why "c:forEach" loop returns nothing in this jsp?

Why this struct with optional values returns nothing?

Non-void function returns nothing dart

ANY function returns nothing when the database is empty

Replace function $$find always returns nothing

Callback function for database query returns nothing

Google spreadsheet custom function returns nothing

Async function to get JSON returns nothing

why this function returns null?

Why function returns null?

Why is this function returning nothing, although there is a match?

Why does .map function return nothing in react

why python function execution gives me nothing

Why is nothing being passed to my overloaded function?

Elastic Search: Why my filtered query returns nothing?

Why fs.readFileSync returns nothing inside a promise on serveside?

Why isn't Stored Procedure returns Nothing even the parameters are correct?

Why sqlite database query returns nothing in python code?