您好,登录后才能下订单哦!
项目中遇到要用xmpp做通讯,原来在的应用跑在linux上用的gloox,现在需要在android上来实现,查了下发现smack最近做了一次大升级,4.0.0发布了,最开始用了smack的库,结果在android上报错,去https://community.igniterealtime.org/ 社区问了下,原来还有个asmack,下了库文件然后写代码:
根据asmack-android-8-4.0.0-rc2.jar 的readme,另外需要dnsjava的库,我用的是dnsjava-2.1.6
最开始发现logcat有一个关于dns的报错,网上查了下发现有说要加下面一句在初始化的时候:
//System.setProperty("sun.net.spi.nameservice.provider.1","dns,dnsjava");
但是后来我发现没有这句,好像也没问题,暂时屏蔽掉了。
asmack的初始化是必须的。
mSmackAndroid = SmackAndroid.init(context);
conf = new ConnectionConfiguration( "wooxonline.com",5222);
SASLAuthentication.supportSASLMechanism("PLAIN",0);
conf.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
conf.setCompressionEnabled(false);
// disable the built-in ReconnectionManager since we handle this
conf.setReconnectionAllowed(false);
conf.setSendPresence(false);
conf.setDebuggerEnabled(true);
XMPPConnection connection = XMPPTCPConnection(conf);
connection.login(g_email, g_password);
最开始少了sasl方式的设置,发现连接没问题,但是login的时候总是返回noresponse error,查了发现asmask对于连接出错抛的异常比较简单,不会细分。
log如下:
connect:
06-17 09:39:09.300 19344-19457/com.wooxclound.homedaemonactivity.app D/SMACK﹕ SENT (0): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
06-17 09:39:12.500 19344-19458/com.wooxclound.homedaemonactivity.app D/SMACK﹕ RCV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1920830504' from='wooxonline.com' version='1.0' xml:lang='en'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
login:
06-17 09:39:21.500 19344-19457/com.wooxclound.homedaemonactivity.app D/SMACK﹕ SENT (0): <auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">AHRlc3QxMUB3b294b25saW5lLmNvbQBhYjEyMzR5eg==</auth>
06-17 09:39:21.500 19344-19344/com.wooxclound.homedaemonactivity.app I/Woox HomeDaemon﹕ onStartCommand(): Intent com.wooxclound.homedaemon.action.XMPP.CONNECTION_CHANGED
06-17 09:39:22.090 19344-19458/com.wooxclound.homedaemonactivity.app D/SMACK﹕ RCV (0): <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
06-17 09:39:22.100 19344-19458/com.wooxclound.homedaemonactivity.app D/SMACK﹕ SENT (0): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
06-17 09:39:22.490 19344-19458/com.wooxclound.homedaemonactivity.app D/SMACK﹕ RCV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='2952941696' from='wooxonline.com' version='1.0' xml:lang='en'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
06-17 09:39:22.540 19344-19346/com.wooxclound.homedaemonactivity.app D/dalvikvm﹕ GC_CONCURRENT freed 311K, 8% free 5028K/5408K, paused 4ms+3ms, total 26ms
06-17 09:39:22.560 19344-19457/com.wooxclound.homedaemonactivity.app D/SMACK﹕ SENT (0): <iq id='Aa7TB-0' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>Smack</resource></bind></iq>
06-17 09:39:23.130 19344-19458/com.wooxclound.homedaemonactivity.app D/SMACK﹕ RCV (0): <iq id='Aa7TB-0' type='result'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>test11@wooxonline.com/Smack</jid></bind></iq>
06-17 09:39:23.130 19344-19457/com.wooxclound.homedaemonactivity.app D/SMACK﹕ SENT (0): <iq id='Aa7TB-1' type='set'><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>
06-17 09:39:23.720 19344-19458/com.wooxclound.homedaemonactivity.app D/SMACK﹕ RCV (0): <iq type='result' id='Aa7TB-1'/>
06-17 09:39:23.730 19344-19454/com.wooxclound.homedaemonactivity.app D/SMACK﹕ User logged (0): test11@wooxonline.com@wooxonline.com:0/Smack
在注册新用户的时候,可以使用accountmanager也可以使用IQ package,方法如下:
public static final int REGISTER_METHOD_ACCOUNT_MANAGER = 0;
public static final int REGISTER_METHOD_IQ_PACKAGE = 1;
public static final int REGISTER_RESULT_SERVER_NO_RESULT = 0;
public static final int REGISTER_RESULT_SUCCESS = 1;
public static final int REGISTER_RESULT_ACCOUNT_EXIST = 2;
public static final int REGISTER_RESULT_FAIL = 4;
public static final int REGISTER_RESULT_NO_CONNECTION = 4;
/**
* register
*
* @param username
* @param password
* @return 1:success 0:server not return 2:account exist 3:fail 4:no connection
*/
public int register(String username, String password) {
if (!((mConnection != null) && mConnection.isConnected())) {
return REGISTER_RESULT_NO_CONNECTION;
} else {
reg_method = REGISTER_METHOD_ACCOUNT_MANAGER;
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("username", username);
attributes.put("password", password);
//attributes.put("email", "");
//attributes.put("name", "");
if (reg_method == REGISTER_METHOD_ACCOUNT_MANAGER) {
try {
if (mAccountManager == null) {
mAccountManager = AccountManager.getInstance(mConnection);
}
mAccountManager.createAccount(username, password, attributes);
} catch (Exception ex) {
L.e(TAG, ex);
if (ex.toString().equalsIgnoreCase("conflict")) {
L.i(XmppManager.class, " account exist!");
return REGISTER_RESULT_ACCOUNT_EXIST;
} else {
L.i(XmppManager.class, " register fail");
return REGISTER_RESULT_FAIL;
}
}
L.i(XmppManager.class, " register success!");
return REGISTER_RESULT_SUCCESS;
} else if (reg_method == REGISTER_METHOD_IQ_PACKAGE) {
try {
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(mConnection.getServiceName());
reg.setAttributes(attributes);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = mConnection.createPacketCollector(filter);
mConnection.sendPacket(reg);
IQ result = (IQ) collector.nextResult(SmackConfiguration.getDefaultPacketReplyTimeout());
collector.cancel();
//System.out.println(result);
if (result == null) {
L.i(XmppManager.class, " no value return by server!");
return REGISTER_RESULT_SERVER_NO_RESULT;
} else if (result.getType() == IQ.Type.ERROR) {
//<error code="409" type="cancel"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>
if (result.getError().toString().equalsIgnoreCase("conflict")) {
L.i(XmppManager.class, " account exist!");
return REGISTER_RESULT_ACCOUNT_EXIST;
} else {
L.i(XmppManager.class, " register fail");
return REGISTER_RESULT_FAIL;
}
} else if (result.getType() == IQ.Type.RESULT) {
L.i(XmppManager.class, " register success!");
//Intent intent = new Intent(DaemonService.ACTION_REGISTER);
return REGISTER_RESULT_SUCCESS;
}
L.e(TAG, ":Should not go there for register process!");
} catch (Exception ex) {
L.e(TAG, ex);
}
}
L.e(TAG, ":Should not go there for register process!");
return REGISTER_RESULT_FAIL;
}
}
}
当账户存在时,返回如下包:
D/SMACK﹕ RCV (0): <iq type="error" id="EzQN5-0" from="ddnas-v2.com" to="ddnas-v2.com/c220b282"><query xmlns="jabber:iq:register"><email> </email><password>jacky</password><username>jacky</username><name> </name></query><error code="409" type="cancel"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
但是geterrorcode()接口似乎在4.0的asmack中被去掉了,所以只能判定error是conflict就认为是账户已经存在。
由于服务器强制使用TLS认证,所以对于连接做了新的配置,然后再openfire server上测试没有问题,但是在公司的服务器出问题了,最先我用的是asmak 4.0.0 rc2的库,在认证challenge的时候服务器似乎没有响应,log如下:
D/SMACK﹕ SENT (0): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
D/SMACK﹕ RCV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='2936112787' from='wooxonline.com' version='1.0' xml:lang='en'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
D/SMACK﹕ SENT (0): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
D/SMACK﹕ RCV (0): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.initReaderAndWriter(XMPPTCPConnection.java:501)
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:648)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:223)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:48)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:82)
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.initReaderAndWriter(XMPPTCPConnection.java:501)
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:648)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:223)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:48)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:82)
D/SMACK﹕ SENT (0): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
D/SMACK﹕ RCV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='3044304500' from='wooxonline.com' version='1.0' xml:lang='en'>
D/SMACK﹕ RCV (0): <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
D/SMACK﹕ SENT (0): <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></auth>
D/SMACK﹕ RCV (0): <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjIyNzI1NzYwOTQiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
D/SMACK﹕ SENT (0): </stream:stream>
W/XMPPConnection﹕ Connection closed with error
java.lang.NullPointerException
at com.novell.sasl.client.DigestMD5SaslClient.DigestCalcHA1(DigestMD5SaslClient.java:447)
at com.novell.sasl.client.DigestMD5SaslClient.createDigestResponse(DigestMD5SaslClient.java:646)
at com.novell.sasl.client.DigestMD5SaslClient.evaluateChallenge(DigestMD5SaslClient.java:356)
at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java:190)
at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication.java:427)
at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:252)
at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:48)
at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:82)
翻了一下asmack社区的帖子https://community.igniterealtime.org/message/240015#240015上说rc3的库解决了这个问题,down下来一试,果然,但是认证还是通不过:
D/SMACK﹕ SENT (0): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
D/SMACK﹕ RCV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='83599252' from='wooxonline.com' version='1.0' xml:lang='en'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
D/SMACK﹕ SENT (0): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
D/SMACK﹕ RCV (0): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.initReaderAndWriter(XMPPTCPConnection.java:501)
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:648)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:223)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:48)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:82)
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.initReaderAndWriter(XMPPTCPConnection.java:501)
W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.proceedTLSReceived(XMPPTCPConnection.java:648)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.parsePackets(PacketReader.java:223)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader.access$000(PacketReader.java:48)
W/System.err﹕ at org.jivesoftware.smack.tcp.PacketReader$1.run(PacketReader.java:82)
D/SMACK﹕ SENT (0): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
D/SMACK﹕ RCV (0): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='1654478887' from='wooxonline.com' version='1.0' xml:lang='en'>
D/SMACK﹕ RCV (0): <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
D/SMACK﹕ SENT (0): <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></auth>
D/SMACK﹕ RCV (0): <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjI4MDgzODM5MDUiLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
D/SMACK﹕ SENT (0): <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9InRlc3QxMkB3b294b25saW5lLmNvbSIsY25vbmNlPSIwNWUxNjVlMjUxZDA2MzM3MzJmZWZjNzBjMDU4ZTkwMDU4YjM0MjE0Mjg4ZDlmNzM1NTAwMDVkOTc4NWIwNmFlIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL3dvb3hvbmxpbmUuY29tIixyZXNwb25zZT05YThiMzkxZjNjM2Q0MzdjOTc0MDNkYzJiNzkyNGU5MixjaGFyc2V0PXV0Zi04LG5vbmNlPSIyODA4MzgzOTA1Ig==</response>
D/SMACK﹕ RCV (0): <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>
D/SMACK﹕ SENT (1): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
D/SMACK﹕ RCV (1): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='3726488975' from='wooxonline.com' version='1.0' xml:lang='en'><stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
D/SMACK﹕ SENT (1): <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
D/SMACK﹕ RCV (1): <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
D/SMACK﹕ SENT (1): <stream:stream to="wooxonline.com" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
D/SMACK﹕ RCV (1): <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='4109710539' from='wooxonline.com' version='1.0' xml:lang='en'>
D/SMACK﹕ RCV (1): <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='k0acyvEdZQ7cl5uD5FTPoiOnuaw='/><register xmlns='http://jabber.org/features/iq-register'/></stream:features>
D/SMACK﹕ SENT (1): <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"></auth>
D/SMACK﹕ RCV (1): <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjQyOTQ3NjMyMTciLHFvcD0iYXV0aCIsY2hhcnNldD11dGYtOCxhbGdvcml0aG09bWQ1LXNlc3M=</challenge>
D/SMACK﹕ SENT (1): <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9InRlc3QxMkB3b294b25saW5lLmNvbSIsY25vbmNlPSI1ODA3MGMzYjIxMTk5Yjc5MzUxYTc3ODkzNTkwYTNiNGFmZmQ2MjYwYTUwNGZjZmY5NTJkMjg1YWE3YmViY2VkIixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL3dvb3hvbmxpbmUuY29tIixyZXNwb25zZT02Mzk5NGYyMzk0YjQxYjkyYjUwYzM3NDg0ZGFkNzQ5ZCxjaGFyc2V0PXV0Zi04LG5vbmNlPSI0Mjk0NzYzMjE3Ig==</response>
D/SMACK﹕ RCV (1): <failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure>
继续翻坛子,https://code.google.com/p/gtalksms/issues/detail?id=262有人发现登陆ID不使用@域名就没有问题,太晕了。
程序跑起来以后,使用xmpp客户端聊天消息接收没问题,但是通过CGI网页pass过来的信息接收不到,初步认为应该是packetfilter的配置不对引起的。
先抓包:
From HTML page:
D/SMACK﹕ RCV (0): <message from='test00@wooxonline.com/17837575071403770533364162' to='test12@wooxonline.com'id='3'><body>{"msg":"hello123"}</body></message>
From XMPP client:
D/SMACK﹕ RCV (0): <message from='test12@wooxonline.com/Gajim'to='test12@wooxonline.com/Smack' xml:lang='en' type='chat'id='30'><body>sajdhs</body><thread>DXPNsxrROrFFuvBNxxOJgaqbFeRNQYKy</thread></message>
但是从http://xmpp.org/extensions/xep-0201.html xmpp协议上来看似乎,所有的message都应该有type和thread段。
最后将filter的配置改了一下,就能抓到了。
//PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class));
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。