libjingle 登录openfire测试
来源:互联网 发布:数据质量 衡量标准 编辑:程序博客网 时间:2024/06/05 23:49
gmail登录不上,而且也不能知道登录状态,因为libjingle是xmpp,所以用openfire作为服务器来测试libjingle
首先,安装openfire,并按openfire要求,初始化环境,开启openfire,并建立用户用户登录
接着,用libjingle的login example来登录openfire,把login代码改动下
login_main.cc 改成(openfire地址192.168.0.108)
/* * libjingle * Copyright 2004--2005, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#include <cstdio>#include <iostream>#include "talk/base/thread.h"#include "talk/xmpp/xmppclientsettings.h"#include "talk/examples/login/xmppthread.h"#include "talk/xmpp/xmppengine.h"int main(int argc, char **argv) { std::cout << "Password: "; std::string auth_cookie; std::getline(std::cin, auth_cookie); std::cout << "User Name: "; std::string username; std::getline(std::cin, username); // Start xmpp on a different thread XmppThread thread; thread.Start(); buzz::XmppClientSettings xcs; talk_base::InsecureCryptStringImpl pass; pass.password() = auth_cookie.c_str(); xcs.set_user(username.c_str()); xcs.set_host("192.168.0.108"); xcs.set_use_tls(buzz::TLS_DISABLED); //xcs.set_auth_cookie(auth_cookie.c_str()); xcs.set_pass(talk_base::CryptString(pass)); xcs.set_server(talk_base::SocketAddress("192.168.0.108", 5222)); thread.Login(xcs); // Use main thread for console input //std::string line; //while (std::getline(std::cin, line)) { // if (line == "quit") //break; //} return 0;}
xmppthread.h
/* * libjingle * Copyright 2004--2005, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#ifndef TALK_EXAMPLES_LOGIN_XMPPTHREAD_H_#define TALK_EXAMPLES_LOGIN_XMPPTHREAD_H_#include "talk/base/thread.h"#include "talk/examples/login/xmpppump.h"#include "talk/examples/login/xmppsocket.h"#include "talk/xmpp/xmppclientsettings.h"#include "talk/xmpp/xmppengine.h"class XmppThread: public talk_base::Thread, XmppPumpNotify, talk_base::MessageHandler {public: XmppThread(); ~XmppThread(); buzz::XmppClient* client() { return pump_->client(); } void ProcessMessages(int cms); void Login(const buzz::XmppClientSettings & xcs); void Disconnect();private: XmppPump* pump_; void log(std::string str); void OnStateChange(buzz::XmppEngine::State state); void OnMessage(talk_base::Message* pmsg);};#endif // TALK_EXAMPLES_LOGIN_XMPPTHREAD_H_
xmppthread.cc
/* * libjingle * Copyright 2004--2005, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */#include "talk/examples/login/xmppthread.h"#include "talk/xmpp/xmppclientsettings.h"#include "talk/examples/login/xmppauth.h"#include "talk/base/fileutils.h"#include "talk/base/logging.h"#include "talk/base/pathutils.h"#include "talk/base/stream.h"#include <stdio.h>using namespace talk_base;namespace {const uint32 MSG_LOGIN = 1;const uint32 MSG_DISCONNECT = 2;struct LoginData: public talk_base::MessageData { LoginData(const buzz::XmppClientSettings& s) : xcs(s) {} virtual ~LoginData() {} buzz::XmppClientSettings xcs;};} // namespacevoid XmppThread::log(std::string str){int sev = LogMessage::GetLogToStream(NULL); StringStream stream1(str);LogMessage::AddLogToStream(&stream1, LS_INFO);LogMessage::RemoveLogToStream(&stream1);}XmppThread::XmppThread() { pump_ = new XmppPump(this); LOG(LS_INFO) << "INFO";}XmppThread::~XmppThread() { delete pump_;}void XmppThread::ProcessMessages(int cms) { talk_base::Thread::ProcessMessages(cms);}void XmppThread::Login(const buzz::XmppClientSettings& xcs) { Post(this, MSG_LOGIN, new LoginData(xcs)); Join();}void XmppThread::Disconnect() { Post(this, MSG_DISCONNECT);}void XmppThread::OnStateChange(buzz::XmppEngine::State state) {printf("buzz::XmppEngine::State: %d\r\n", state); }void XmppThread::OnMessage(talk_base::Message* pmsg) {printf("XmppThread OnMessage\r\n"); if (pmsg->message_id == MSG_LOGIN) { ASSERT(pmsg->pdata != NULL); LoginData* data = reinterpret_cast<LoginData*>(pmsg->pdata); pump_->DoLogin(data->xcs, new XmppSocket(buzz::TLS_DISABLED), new XmppAuth()); delete data; } else if (pmsg->message_id == MSG_DISCONNECT) { pump_->DoDisconnect(); } else { ASSERT(false); }}编译代码,输入用户名和密码后,openfire显示出用户
而终端加入了log,显示了从start 到opening,open状态
登录log:
connecting...[003:181] SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Tue Oct 21 17:06:46 2014[003:187] <stream:stream to="192.168.0.108" xml:lang="*" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">logging in...[003:202] RECV <<<<<<<<<<<<<<<<<<<<<<<<< : Tue Oct 21 17:06:46 2014[003:202] <?xml version='1.0' encoding='UTF-8'?>[003:202] <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="jacklam-pc" id="f71662e" xml:lang="*" version="1.0">[003:203] RECV <<<<<<<<<<<<<<<<<<<<<<<<< : Tue Oct 21 17:06:46 2014[003:203] <stream:features>[003:203] <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">[003:203] </starttls>[003:203] <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">[003:204] <mechanism>[003:204] DIGEST-MD5[003:204] </mechanism>[003:204] <mechanism>[003:204] PLAIN[003:204] </mechanism>[003:204] <mechanism>[003:204] ANONYMOUS[003:204] </mechanism>[003:204] <mechanism>[003:204] CRAM-MD5[003:204] </mechanism>[003:204] </mechanisms>[003:204] <compression xmlns="http://jabber.org/features/compress">[003:205] <method>[003:205] zlib[003:205] </method>[003:205] </compression>[003:205] <auth xmlns="http://jabber.org/features/iq-auth"/>[003:205] <register xmlns="http://jabber.org/features/iq-register"/>[003:205] </stream:features>[003:205] SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Tue Oct 21 17:06:46 2014[003:205] [003:205] <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN" auth:allow-non-google-login="true" auth:client-uses-full-bind-result="true" xmlns:auth="http://www.google.com/talk/protocol/auth">[003:205] ## TEXT REMOVED ##[003:205] </auth>[003:222] RECV <<<<<<<<<<<<<<<<<<<<<<<<< : Tue Oct 21 17:06:46 2014[003:222] <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>[003:222] SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Tue Oct 21 17:06:46 2014[003:222] <stream:stream to="192.168.0.108" xml:lang="*" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">[003:224] RECV <<<<<<<<<<<<<<<<<<<<<<<<< : Tue Oct 21 17:06:46 2014[003:224] <?xml version='1.0' encoding='UTF-8'?>[003:224] <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="jacklam-pc" id="f71662e" xml:lang="*" version="1.0">[003:224] <stream:features>[003:224] <compression xmlns="http://jabber.org/features/compress">[003:224] <method>[003:224] zlib[003:224] </method>[003:224] </compression>[003:224] <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>[003:224] <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>[003:224] </stream:features>[003:225] SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Tue Oct 21 17:06:46 2014[003:225] [003:225] <iq type="set" id="0">[003:225] <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">[003:225] <resource>[003:225] pcp[003:225] </resource>[003:225] </bind>[003:225] </iq>[003:229] RECV <<<<<<<<<<<<<<<<<<<<<<<<< : Tue Oct 21 17:06:46 2014[003:229] <iq type="result" id="0" to="jacklam-pc/f71662e">[003:229] <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">[003:229] <jid>[003:229] jacklam200@jacklam-pc/pcp[003:230] </jid>[003:230] </bind>[003:230] </iq>[003:230] SEND >>>>>>>>>>>>>>>>>>>>>>>>> : Tue Oct 21 17:06:46 2014[003:230] <iq type="set" id="1">[003:230] <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>[003:230] </iq>[003:233] RECV <<<<<<<<<<<<<<<<<<<<<<<<< : Tue Oct 21 17:06:46 2014[003:233] <iq type="result" id="1" to="jacklam200@jacklam-pc/pcp"/>logged in...
1 0
- libjingle 登录openfire测试
- LibJingle连接openfire 错误
- libjingle与openfire基本交互
- libjingle登录程序调试通过
- 利用Jmeter3.1测试Openfire--登录和批量创建用户
- libjingle
- Libjingle
- Libjingle
- openfire登录验证AuthProvider
- openfire 登录不上
- Openfire不能登录
- openfire登录验证AuthProvider
- smack 登录openfire
- xmpp openfire 邮箱登录
- Spark 登录Openfire
- Tsung测试openfire
- TSung 对Openfire测试
- Tsung压力测试openfire
- 在CentOS 6.5中安装与配置Tomcat-7方法
- 改变MFC CCheckBox控件默认字体的颜色
- UVA10066(DP)
- Linux磁盘管理
- 字符串的简单操作
- libjingle 登录openfire测试
- Hat's Fibonacci(杭电1250)
- FFmpeg滤镜代码级分析
- error: null pointer exception in JaxWsDynamicClientFactory
- MyEclipse10 安装SVN后,每次启动myeclipse弹出“SubVersion Native Library Not Availbale”窗口
- vs2010项目转换为vs2008项目
- 软件工程-关于词频统计程序设计实现分析
- POJ 1236 Network of Schools(强连通分量)
- POJ 3254 状压DP