Getting list from XMPP in Swift

Hi I'm new to IPhone development and I don't know anything about Objective c. I am developing an application using swift. I added XMPP framework to my project and the XMPP connection was successful. I am using the following code to set up my connection

func setupStream () {

        xmppStream = XMPPStream()
        xmppStream!.addDelegate(self, delegateQueue: dispatch_get_main_queue())
        xmppReconnect = XMPPReconnect();
        xmppRosterStorage = XMPPRosterCoreDataStorage();
        xmppRoster = XMPPRoster(rosterStorage: xmppRosterStorage);



        xmppvCardStorage = XMPPvCardCoreDataStorage.sharedInstance();
        xmppvCardTempModule = XMPPvCardTempModule(withvCardStorage:xmppvCardStorage);

        xmppvCardAvatarModule = XMPPvCardAvatarModule(withvCardTempModule:xmppvCardTempModule);

        xmppCapabilitiesStorage = XMPPCapabilitiesCoreDataStorage.sharedInstance();
        xmppCapabilities = XMPPCapabilities(capabilitiesStorage: xmppCapabilitiesStorage);

        // SET UP ALL XMPP MODULES
        xmppRoster!.autoFetchRoster = true;
        xmppRoster!.autoAcceptKnownPresenceSubscriptionRequests = true;

        xmppCapabilities!.autoFetchHashedCapabilities = true;
        xmppCapabilities!.autoFetchNonHashedCapabilities = true;

        xmppMessageArchivingStorage = XMPPMessageArchivingCoreDataStorage.sharedInstance();
        xmppMessageArchivingModule = XMPPMessageArchiving(messageArchivingStorage: xmppMessageArchivingStorage);
        xmppMessageArchivingModule!.clientSideMessageArchivingOnly = true;


        // Activate xmpp modules
        xmppReconnect!.activate(xmppStream);
        xmppRoster!.activate(xmppStream);
        xmppvCardTempModule!.activate(xmppStream);
        xmppvCardAvatarModule!.activate(xmppStream);
        xmppCapabilities!.activate(xmppStream);
        xmppMessageArchivingModule!.activate(xmppStream);


        xmppRoster!.addDelegate(self, delegateQueue:dispatch_get_main_queue());
        xmppMessageArchivingModule!.addDelegate(self, delegateQueue:dispatch_get_main_queue());


          }

      

And the following methods work fine

func xmppStream(sender: XMPPStream?, didReceiveMessage: XMPPMessage?) {
}


func xmppStream(sender: XMPPStream?, didReceivePresence: XMPPPresence?) {
}

      

Now I want to get the list of the list from XMPP. I found delegate method in list class

(void)xmppRosterDidEndPopulating:(XMPPRoster *)sender;

      

But how to use this in Swift class. Please help me....

+3


source to share


1 answer


Finally I got the asnwer by setting the delegate like this



func xmppRosterDidEndPopulating(sender: XMPPRoster?){
        var jidList = xmppRosterStorage?.jidsForXMPPStream(xmppStream)
        println("List=\(jidList)")

    }

      

+1


source







All Articles