Getting Roster from XMPP in Swift -
hi new iphone development , don't know in objective c. developing application using swift. added xmpp framework in project , xmpp connection successful. using following code set 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 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 following methods working fine
func xmppstream(sender: xmppstream?, didreceivemessage: xmppmessage?) { } func xmppstream(sender: xmppstream?, didreceivepresence: xmpppresence?) { }
now want roster list xmpp. found delegate method in roster class
(void)xmpprosterdidendpopulating:(xmpproster *)sender;
but how use in swift class. please me....
finally got asnwer setting delegate this
func xmpprosterdidendpopulating(sender: xmpproster?){ var jidlist = xmpprosterstorage?.jidsforxmppstream(xmppstream) println("list=\(jidlist)") }
Comments
Post a Comment