打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
【转】gloox不能注册新用户的问题

gloox不能注册新用户的问题

gloox不能注册新用户的问题
经过测试,发现gloox 0.8版自带的测试程序register_test.cpp,是没有办法注册新用户的
前面的三步是这样没错
Client->Server 001
<?xml version='1.0' ?>
<stream:stream to='jabber.org
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
xml:lang='en'
version='1.0'>
客户端向服务器建立连接,version='1.0'代表客户端的所用的XMPP的版本,没有表示是0.x版,o.x版与1.0版的验证方式不同
S->C 002
<?xml version='1.0'?>
<stream:stream xmlns:stream='http://etherx.jabber.org/streams'
xmlns='jabber:client'from='jabber.org'
version='1.0'
id='7mh6bxa8x95js1ubvkxyupysze2xpz6jhxtrzzpq'>
服务器响应连接
S->C 003
<stream:features xmlns:stream='http://etherx.jabber.org/streams'>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
</stream:features>
服务器返回支持的验证方式
第四步应该就是发送注册新用户的请求了,但应际上,它还是发登录验证,未注册的当然就验证不通过,连接也就断开了
我改了一些代码,让注册可以实现
1. 继承Client类,重载了handleNormalNode函数
class RegisterClient : public Client
{
public:
RegisterClient( const JID& jid, const std::string& password, int port = -1 ):
Client(jid,password,port)
{
}
bool RegisterClient::handleNormalNode( Stanza *stanza )
{
if( stanza->name() == "stream:features" )
{
//fastxyf modify
notifyOnConnect();
return true;
};
return false;
};
};
2. 将RegTest类中star函数中的
j = new Client( jid, szPassword );
改为:
j = new RegisterClient( jid, szPassword );
这样就可以注试通过了
新注册的用户名,密码是在handleRegistrationFields函数中指定的
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
XMPP协议的原理介绍
IM开发【5】
RC4算法
Linux 网桥代码分析 (一)
Linux Gstreamer and GST
【C++】Winsock套接字编程,struct sockaddr、sockaddr
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服