How to create MultiUserChatRoom using XMPPFramework in iPhone

北城余情 提交于 2020-01-23 11:22:12

问题


I am developing Chat Application using XMPPFramwwork in iPhone.I successfully completed one to one chat,now i want to develop multiuser chat in my application.

I tried the fallowing code but any delegate methods of XMPPRoomDelegate are not called.how can i start to create chat room.When and how the roomdelegate methods get called....any reply thanks inadvance.

XMPPStream *xmppStream = [[XMPPStream alloc] init];

XMPPRoomCoreDataStorage *xmppRoomStorage  = [XMPPRoomCoreDataStorage sharedInstance];

XMPPJID *roomJID = [XMPPJID jidWithString:@"vvreddy50@gmail.com"];

xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:xmppRoomStorage jid:roomJID dispatchQueue:dispatch_get_main_queue()];

[xmppRoom   activate:xmppStream];
[xmppRoom   fetchConfigurationForm];
[xmppRoom   configureRoomUsingOptions:nil];
[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom   addDelegate:self delegateQueue:dispatch_get_main_queue()];

回答1:


Two problems:

  1. XMPPFramework is mostly asynchronous. That means you need to call -fetchConfigurationForm after you've authenticated, in your -xmppStreamDidAuthenticate: method.
    If those two calls need to be made in sequence, then call -configureRoomUsingOptions in -xmppRoom:didFetchConfigurationForm:.

  2. Nothing at all will happen unless you call -connect: on the stream. Make sure to implement -xmppStreamDidConnect: and initiate authentication with the server in that method.



来源:https://stackoverflow.com/questions/15401543/how-to-create-multiuserchatroom-using-xmppframework-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!