如何在iPhone中使用XMPPFramework创建MultiUserChatRoom [英] How to create MultiUserChatRoom using XMPPFramework in iPhone

查看:57
本文介绍了如何在iPhone中使用XMPPFramework创建MultiUserChatRoom的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iPhone中的XMPPFramwwork开发聊天应用程序.我成功完成了一对一的聊天,现在我想在我的应用程序中开发多用户聊天.

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.

我尝试了休闲代码,但是没有调用XMPPRoomDelegate的任何委托方法.我如何开始创建聊天室.何时以及如何调用roomdelegate方法.

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. XMPPFramework通常是异步的.这意味着您需要在通过身份验证后使用-xmppStreamDidAuthenticate:方法调用-fetchConfigurationForm.
    如果需要依次进行这两个调用,请在-xmppRoom:didFetchConfigurationForm:中调用-configureRoomUsingOptions.

  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:.

除非您在流上调用-connect:,否则什么都不会发生.确保实现-xmppStreamDidConnect:并使用该方法启动与服务器的身份验证.

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.

这篇关于如何在iPhone中使用XMPPFramework创建MultiUserChatRoom的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆