2013-02-28 51 views
2

我在ejabberd安装工作,我成功地配置服务器,但是在客户端,我们需要XMPP架构对于这一点,需要XMPP架构

我用Google搜索我得到了以下链接

http://deusty.blogspot.in/2008/08/xmppframework-on-iphone.html

http://iphone4developer.blogspot.in/2011/07/how-to-add-xmpp-in-your-ios-project.html

我下载了robbiehanson/XMPPFramework但它引发错误,有些链接给我404错误(它们删除)

我下载了Jabber客户端从这个链接(https://github.com/funkyboy/Building-a-Jabber-client-for-iOS),但XMPP架构文件从应用程序中引发错误(那些已被删除)

我有一个样品是iPhoneXMPP样本,但它抛出的错误是“无法连接到服务器。检查xmppStream.hostName“我在willSecureWithSettings方法给我的主机名

疑惑:

1)请指引我去下载正确的XMPP架构与出错误

2)如何配置ejabber客户端?

请指引我

感谢很多提前

+0

2几年前,我下载了它的基本版本。不是更新的,并且完成了一个POC推送通知。在那里我配置了gtalk,后来poc被纳入雷达。现在我没有任何源代码可以帮助你,但我想帮助你... – 2013-02-28 09:28:38

+0

好的..谢谢你@AnoopVaidya – Babul 2013-02-28 09:29:51

+0

@BabulI已经将XMPP框架及其所有依赖项添加到我的iPhone聊天应用程序中,并且它没有给出任何错误(已成功构建)。现在你可以帮我,现在我需要在我的应用程序中添加XMPP框架后做些什么..?谢谢 – 2014-01-23 07:55:41

回答

5

我大约6个月后从这个链接下载了robbiehanson/XMPPFramework:https://github.com/robbiehanson/XMPPFramework。我遵循Getting Started部分中提到的步骤。它没有抛出任何错误。试着按照这些步骤来设置你的应用程序的xmppframework。

在示例应用程序中,我找到了我在启动应用程序时调用的函数setupStream()。在这个函数中,我创建一个xmppStream并激活我的应用程序中需要的不同模块。例如

xmppStream = [[XMPPStream alloc] init]; 

    // Activate xmpp modules after creating them 

    [xmppReconnect   activate:xmppStream]; 
    [xmppRoster   activate:xmppStream]; 
    [xmppvCardTempModule activate:xmppStream]; 
    [xmppvCardAvatarModule activate:xmppStream]; 
    [xmppCapabilities  activate:xmppStream]; 

    // Add ourself as a delegate to anything we may be interested in 

    [xmppStream addDelegate:self delegateQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; 


[xmppStream setHostName:XMPPHOST]; 
[xmppStream setHostPort:5222]; 

// You may need to alter these settings depending on the server you're connecting to 
allowSelfSignedCertificates = NO; 
allowSSLHostNameMismatch = NO; 

设置流之后,你需要做这样的鉴定:

- (BOOL)connect:(NSString *)myJID //username registered with server 
{ 
    if (![xmppStream isDisconnected]) { 
     return YES; 
    } 

    if (myJID == nil) { 
     return NO; 
    } 

    [xmppStream setMyJID:[XMPPJID jidWithString:myJID]]; 

    NSError *error = nil; 
    if (![xmppStream connect:&error]) 
    {   
     if(DEBUG) 
     { 
      NSLog(@"ERROR: Not connected to XMPP Server"); 
     } 
     DDLogError(@"Error connecting: %@", error); 
     return NO; 
    } 
    return YES; 
} 

此功能将被框架调用,通过这里的密码:

- (void)xmppStreamDidConnect:(XMPPStream *)sender 
{ 
    if(sender == xmppStream) 
    { 
     //DDLogVerbose(@"In xmppStream: %@: %@", THIS_FILE, THIS_METHOD); 

     isXmppConnected = YES; 

     NSError *error = nil; 

     if (![[self xmppStream] authenticateWithPassword:password error:&error]) 
     { 
      DDLogError(@"Error authenticating: %@", error); 
     } 
    }  
} 

现在如果用户通过认证,此功能将被称为:

- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender 
{ 
    if(sender == xmppStream) 
    { 
     [self goOnline]; 
    } 
} 

goOnline将发送用户的存在服务器:

- (void)goOnline 
{ 
    XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit 
    [xmppStream sendElement:presence]; 
} 

现在,您可以发送/接收消息/存在等

+0

@AkashI已经将XMPP框架及其所有依赖项添加到我的iPhone聊天应用程序中,并且它不会给出任何错误(成功建成)。现在你可以帮我,现在我需要在我的应用程序中添加XMPP框架后做什么事情??谢谢 – 2014-01-23 07:54:57

+0

嗨兄弟,模块在我的代码中没有在我的代码中显示错误,并且“connect “方法现在没有在xmppstream ..我没有在代码中的错误,但它没有连接到服务器。我有一个服务器托管在那里...请尽快帮助我.. – 2015-05-01 15:23:20