我剛剛在我的Suse-Linux EC2實例中安裝了openfire服務器,並且我通過除了管理員之外創建了一個名爲'balaji'的用戶來配置openfire服務器。ilibjingle與Openfire服務器 - 無法登錄
然後我安裝了iOS平臺的ilibjingle代碼,並且能夠構建它。我在模擬器中運行它,它對我的gmail-id完美運行。它已登錄,然後將用戶從名單中列出。
然後我修改了代碼以指向我的openfire服務器IP地址,並給出了用戶名'balaji'(我在openfire中創建的用戶名)和相應的密碼。我在openfire服務器上也有一個自簽名的SSL證書。當我運行這個代碼時,它能夠連接,但無法登錄(我相信)。 ilibjingle代碼應該從Connect到Login登錄到名單列表。當我使用我的openfire服務器運行時,它從連接到登錄,但沒有任何超出。
什麼可能會出錯?我應該修改openfire服務器中的任何內容來完成這項工作嗎?這是我的iPhone代碼。
在rootviewcontroller.mm中,我有以下代碼片段。
-(void) _mainGtalkThread:(id)sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//you need to setup name and passwd manuelly here
char *name = "balaji";
char *password = "mypasswd";
[self gtalk_main:(char*)name userpassword:(char*)password];
[pool release];
}
-(int) gtalk_main:(char*)un userpassword:(char*)password
{
// This app has three threads. The main thread will run the XMPP client,
// which will print to the screen in its own thread. A second thread
// will get input from the console, parse it, and pass the appropriate
// message back to the XMPP client's thread. A third thread is used
// by MediaSessionClient as its worker thread.
buzz::Jid jid;
talk_base::InsecureCryptStringImpl pass;
std::string username = un;
if (username.find('@') == std::string::npos) {
username.append("@localhost");
}
jid = buzz::Jid(username);
if (!jid.IsValid() || jid.node() == "") {
printf("Invalid JID. JIDs should be in the form [email protected]\n");
return 1;
}
pass.password() = password;
buzz::XmppClientSettings xcs;
xcs.set_user(jid.node());
//xcs.set_resource("call");
xcs.set_host(jid.domain());
xcs.set_pass(talk_base::CryptString(pass));
xcs.set_use_tls(false);
xcs.set_allow_plain(true);
xcs.set_server(talk_base::SocketAddress("50.37.185.206", DEFAULT_PORT));
printf("Logging in as %s with user as %s\n", jid.Str().c_str(), jid.node().c_str());
talk_base::InitializeSSL();
talk_base::Thread athread;
talk_base::ThreadManager::SetCurrent(&athread);
talk_base::Thread* main_thread = talk_base::Thread::Current();
assert(main_thread!=NULL);
XmppPump pump;
//CallClient *client = new CallClient(pump.client());
gtalkClient_ = new gtalkClient(pump.client(), self);
pump.DoLogin(xcs, new XmppSocket(true), NULL);
main_thread->Run();
return 0;
}
,並在另一個文件「gtalkclient.mm」,我有以下幾點:
gtalkClient::gtalkClient(buzz::XmppClient* xmpp_client, void * controller) :
xmpp_client_(xmpp_client), controller_(controller), media_engine_(NULL),
media_client_(NULL), call_(NULL), incoming_call_(false), auto_accept_(false),
pmuc_domain_("conference.localhost"), local_renderer_(NULL), remote_renderer_(NULL),
roster_(new RosterMap), portallocator_flags_(0)
{
xmpp_client_->SignalStateChange.connect(this, >alkClient::OnStateChange);
}
void gtalkClient::OnStateChange(buzz::XmppEngine::State state)
{
RootViewController * tvc = (RootViewController*)controller_;
switch (state) {
case buzz::XmppEngine::STATE_START:
printf("connecting...");
[tvc.roster_ removeAllObjects];
[tvc.roster_ addObject:@"connecting..."];
[tvc reloadTableViewData];
break;
case buzz::XmppEngine::STATE_OPENING:
printf("logging in...");
[tvc.roster_ removeAllObjects];
[tvc.roster_ addObject:@"logging in..."];
[tvc reloadTableViewData];
break;
case buzz::XmppEngine::STATE_OPEN:
printf("logged in...");
[tvc.roster_ removeAllObjects];
[tvc.roster_ addObject:@"logged in..."];
[tvc reloadTableViewData];
InitPhone();
InitPresence();
// prepare to add roster
[tvc.roster_ removeAllObjects];
break;
case buzz::XmppEngine::STATE_CLOSED:
buzz::XmppEngine::Error error = xmpp_client_->GetError(NULL);
printf("logged out...%s", strerror(error).c_str());
[tvc.roster_ removeAllObjects];
[tvc.roster_ addObject:@"logged out..."];
[tvc reloadTableViewData];
Quit();
}
}
撤消對rev65上xmppsocket.cc所做的更改(當libjingle更新至0.5.6版時): http://code.google.com/p/libjingle/source/diff?spec=svn95&r=65&format=在這個提交中,他們刪除了兩行允許未知證書頒發機構的證書。在這個提交中,他們刪除了兩行允許未知證書頒發機構頒發的證書。 – Shirs
您可以使用您的答案下方的編輯鏈接進行更改。 – oers
這是我的第一個答案,我是新的stackoverflow。感謝您的意見 – Shirs