[英]Smack api and Openfire server presence error
I am developing a chat application using Smack api and I got stuck at receiving presence packets. 我正在使用Smack api开发聊天应用程序,但是我陷于接收状态数据包。
Tested with Smack 3.2.2 and 3.3.0. 使用Smack 3.2.2和3.3.0测试。
These problems involve only using Openfire server 3.8.1. 这些问题仅涉及使用Openfire服务器3.8.1。
First :I am sending the presence packet from Spark and receiving it with success 首先 :我正在从Spark发送状态数据包并成功接收它
second I am updating and sending presence packet from Spark client to my own: 第二我正在更新并从Spark客户端向我自己发送状态数据包:
<presence id="b8nyI-95">
<status>Free to chat</status>
<priority>1</priority>
<show>chat</show>
<x xmlns="vcard-temp:x:update">
<photo>d37b60faea717f9f7ca08bef1504d2de68a789eb</photo>
</x>
<x xmlns="jabber:x:avatar">
<hash>d37b60faea717f9f7ca08bef1504d2de68a789eb</hash>
</x>
</presence>
and receiving back in Spark debug : 并在Spark debug中接收回来:
<presence id="b8nyI-95" to="test2@localhost/Spark 2.6.3" from="test3" type="error">
<error code="404" type="CANCEL">
<remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</presence>
no packet is received in my own client. 我自己的客户端未收到任何数据包。 This appears only when I try to update my presence in Spark. 仅当我尝试更新Spark中的状态时才会显示。
testing with another xmpp server : I think it's ejabberd 用另一个xmpp服务器进行测试: 我认为这是ejabberd
Sending presence from Spark : 从Spark发送状态:
<presence id="B0ANe-55">
<status>Free to chat</status>
<priority>1</priority>
<show>chat</show>
</presence>
* Receiving it into my chat app * * 接收到我的聊天应用程序中*
<presence from='test2@maxciceu.p1.im/Spark 2.6.3' to='test3@maxciceu.p1.im/Smack' id='B0ANe-55'>
<status>Free to chat</status>
<priority>1</priority>
<show>chat</show>
</presence>
Both rosters have subscription set to : both 这两个名册有订阅设置为: 两
-with Openfire I am able to : connect, receive roster list (it gets the presence that is at the moment of initialization), send and receive messages, send files . -使用Openfire,我能够:连接,接收花名册列表(它获得初始化时的状态),发送和接收消息,发送文件。
---can't do : update roster presence: tried with RosterListener and reloading the roster into my list ---无法做:更新名册是否存在:尝试使用RosterListener并将名册重新加载到我的列表中
I've added a RosterListener 我添加了一个RosterListener
Roster roster = Client.getClient().connection.getRoster();
roster.addRosterListener(new RosterListener() {
@Override
public void entriesAdded(Collection<String> addresses) {}
@Override
public void entriesDeleted(Collection<String> addresses) {}
@Override
public void entriesUpdated(Collection<String> addresses) {}
@Override
public void presenceChanged(Presence presence) {
System.out.println("Presence changed: " + presence.getFrom() + " " + presence);
}
});
->Doesn't work when updating the presence of rosters with Openfire // with the other server everything is fine. ->在其他服务器上使用Openfire //更新名册是否存在时不起作用。
->also added (don't know if it helps or not with my problem): ->还添加了(不知道它对我的问题是否有帮助):
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
if (sdm == null){
sdm = new ServiceDiscoveryManager(connection);}
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("http://jabber.org/protocol/disco#item");
sdm.addFeature("http://jabber.org/protocol/caps");
JingleManager.setJingleServiceEnabled();
ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider());
Already went through Google and StackOverflow. 已经通过了Google和StackOverflow。
If anyone can help I would appreciate. 如果有人可以帮助,我将不胜感激。
Problem is solved after a system reinstall. 重新安装系统后问题已解决。 I did a clean install of ubuntu and installed Openfire using this tutorial : http://www.thefanclub.co.za/how-to/how-setup-im-voip-server-using-openfire-ubuntu-1204 . 我使用本教程进行了全新安装ubuntu并安装了Openfire: http : //www.thefanclub.co.za/how-to/how-setup-im-voip-server-using-openfire-ubuntu-1204 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.