2013-02-28 74 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