这是关于发布在这里
我能够将我的PC连接到本地的本地tigase服务器设置(我正在使用Smack API).现在,当我想通过Wi-Fi将Android Phone连接到该服务器时,我遇到了问题.我能够通过使用客户端Beem连接到本地服务器android.My XMPP服务器的域名是我的PC名称"mwbn43-1",IP地址是"192.168.0.221"(我能够ping这个服务器从Android终端模拟器).在Beem设置中有一个高级选项,我可以指定我要连接的服务器(我已经将其作为IP地址).如果我没有设置此选项,我无法conect.Now这里是的片段代码我用于我的Android客户端.
XMPPConnection.DEBUG_ENABLED = true;
ConnectionConfiguration config = new ConnectionConfiguration("mwbn43-1",5222);
//ConnectionConfiguration config = new ConnectionConfiguration("192.168.0.221",5222);
config.setSASLAuthenticationEnabled(false);
config.setCompressionEnabled(false);
XMPPConnection xmpp = new XMPPConnection(config);
try {
xmpp.connect();
xmpp.login("admin@mwbn43-1", "tigase");
String host = xmpp.getHost();
String id = xmpp.getConnectionID();
int port = xmpp.getPort();
boolean i = false;
i = xmpp.isConnected();
if(i)
{answer = "Connected to " + host + " via port " + port + " with ID " + id;
answerfield.setText(answer);}
}//end try
catch (XMPPException e) {
answerfield.setText("Failed …Run Code Online (Sandbox Code Playgroud) 我在Android上开发了一个应用程序,它利用Smack API连接到XMPP服务器.在这个应用程序中,我硬编码用户登录信息,即用户名和密码.
xmpp.login("admin","tigase");
我收到来自不同用户的数据包
PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class),new FromContainsFilter("ameya @ mwbn43-1"));
现在我面临的问题是,当我在2个不同的Android设备上运行相同的应用程序时,一个设备会覆盖其他设备凭据,因此当我尝试发送数据时,只有其中一个获得它.AFAIK在普通的Google聊天中,用户可以从两个不同的地方登录同一个帐户,并且可以同时在这两个地方接收消息.
谁能告诉我可能是什么问题?它与Smack API有什么关系?
谢谢,
Ameya
我目前正在研究我的大学项目,这是一个Android-App,它应该向服务器提供数据.
为此,我需要通过XMPP与服务器建立或多或少的一致连接.连接在100%的时间内并不是很重要,但是因为系统应该或多或少地对用户不可见,所以用户交互应该是最小的.
服务器和客户端都是xmpp-clients.我jabber.org用作xmpp服务器.
我有一个Android服务,它建立与服务器的连接并提供数据,这很好.
现在我尝试在连接丢失或从Wifi更改为GSM时重新连接服务.我想尝试使用广播接收器来监听NETWORK_STATE_CHANGED_ACTION.但我甚至没有这么做.
这是问题:我尝试运行应用程序,然后只是禁用我的WiFi.我的电话比自动切换到GSM,我失去了我的连接(我预期).但是当我尝试手动重新连接(例如重新启动服务)时,我从服务器获得错误.我的状态仍然"可用".从那一刻起,它需要太长时间,直到我再次连接.
06-29 18:12:14.888: WARN/System.err(14246): resource-constraint(500)
06-29 18:12:14.890: WARN/System.err(14246): at org.jivesoftware.smack.NonSASLAuthentication.authenticate(NonSASLAuthentication.java:110)
06-29 18:12:14.890: WARN/System.err(14246): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:404)
06-29 18:12:14.890: WARN/System.err(14246): at org.jivesoftware.smack.XMPPConnection.login(XMPPConnection.java:349)
....
Run Code Online (Sandbox Code Playgroud)
我实际连接到xmpp服务器,但它不传递我的消息:
06-29 18:12:14.882: INFO/System.out(14246): 06:12:14 nachm. RCV (1079704816): <iq type='error' id='7rhk4-70'><error code='500' type='wait'><resource-constraint xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
Run Code Online (Sandbox Code Playgroud)
有时我没有收到错误,但仍然没有传递消息.
所以我认为服务器不允许我连接,因为在尝试重新连接之前我没有断开连接.我发现这很奇怪,因为我认为你甚至可以从多个客户端连接到一个帐户.
我发布了一些我认为可能相关的代码:
public void connectToServer() throws XMPPException {
ConnectionConfiguration config = new ConnectionConfiguration(
serverADD, port,
service);
connection = new XMPPConnection(config);
connection.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
connection.login(user_JID,password);
Presence presence = new Presence(Presence.Type.available);
presence.setStatus("available");
presence.setPriority(24);
presence.setMode(Presence.Mode.available);
connection.sendPacket(presence);
}
Run Code Online (Sandbox Code Playgroud)
这是我发送消息的方式: …
我尝试在我的基于Smack-API的jabber客户端上实现用户搜索.它可以创建用户使用:
AccountManager manager = conn.getAccountManager();
manager.createAccount(usename,password);
Run Code Online (Sandbox Code Playgroud)
但是,我需要添加一个在创建帐户之前首先搜索"现有"用户的功能,但我找不到任何直接的方法来执行此操作.有谁可以提供我的提示?
谢谢.
我正试图在Android上实现一个简单的Facebook聊天应用程序.它允许用户登录,之后应用程序打开一个新的ListActivity枚举用户的在线联系人,点击一个项目,另一个Activity打开他们的对话将发生的地方.
调用用户登录的第一个屏幕MainActivity.它包含两个EditTexts:一个用于FB用户名,另一个用于密码.还有两个按钮:清除,清空EditTexts,然后单击确定,执行以下AsyncTask new LoginTask().execute():
class LoginTask extends AsyncTask<Void, Void, Void> {
private ProgressDialog loading;
@Override
protected void onPreExecute() {
loading = ProgressDialog.show(MainActivity.this, "", "Loading...");
}
@Override
protected Void doInBackground(Void... params) {
// setup XMPP connection
ConnectionConfiguration config = new ConnectionConfiguration(
"chat.facebook.com", 5222, "chat.facebook.com");
config.setDebuggerEnabled(true);
config.setSASLAuthenticationEnabled(true); // TRUE for fb
conn = new XMPPConnection(config);
try {
// attempt login
conn.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
conn.login(login_field.getText().toString(),
pwd_field.getText().toString(), "");
Log.d("TRACE", "isAuthenticated? " + conn.isAuthenticated()); …Run Code Online (Sandbox Code Playgroud) 是什么方式在smack库中让我能够更新我的任何联系人的vcard的变化我尝试了roster监听器和数据包监听器,听取IQ数据包,但我无法得到任何东西
我要收到的消息包.
<message to="39@domainname.com/smack" chat_id="73392"
custom_packet="true" user_id="44" manager_id="39" time_stamp="0" website_id="0"
visitor_name="John" end_time="False" xml:lang="en-us" type="groupchat"
from="room73392@conference.domainname.com/39">
<body>Hello</body>
<x xmlns="http://jabber.org/protocol/muc#user">
<status xmlns="" code="0"/>
</x></message>
Run Code Online (Sandbox Code Playgroud)
我收到的消息包.
<message to="44@domainname.com/Smack"
from="room73407@conference.domainname.com/Visitor1171" type="groupchat">
<body>Hello</body>
<delay xmlns="urn:xmpp:delay"></delay>
<x xmlns="jabber:x:delay" stamp="20120917T05:57:19"
from="4732abb5@domainname.com/4732abb5">
</x></message>
Run Code Online (Sandbox Code Playgroud)
我有一个smack的源代码,这是包类.任何人都可以帮我制作自定义数据包.任何帮助修改源代码表示赞赏.
代码:
public abstract class Packet {
protected static final String DEFAULT_LANGUAGE =
java.util.Locale.getDefault().getLanguage().toLowerCase();
private static String DEFAULT_XML_NS = null;
/**
* Constant used as packetID to indicate that a packet has no id. To indicate that a packet
* has no id set this constant …Run Code Online (Sandbox Code Playgroud) 如何订阅在SMACK中收听用户可用性状态更改?
要获取用户的可用性状态,请使用以下命令:
XMPPConnection.getRoster().getPresence(name).isAvailable();
Run Code Online (Sandbox Code Playgroud)
但是我如何订阅以便在状态发生变化时收到一些通知?(所以我没有投票).
对于我的xmpp堆栈的集成测试,我在localhost上设置了一个vysper服务器(0.7).现在我想在版本4.0.2中使用smack-core和smack-tcp连接到服务器.
问题:
Caused by: javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Run Code Online (Sandbox Code Playgroud)
由于smack 4 api已经发生了很大的变化,到目前为止发现的例子已经不能再使用了.以前有人试过吗?
我正在使用Samck 4.1.0-alpha库来创建Xmpp客户端.我创建了有效的用户.我试图通过代码发送消息.但得到错误.代码:
new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
ConnectionConfiguration config = new ConnectionConfiguration("jabb3r.org", 5222, "jabb3r.org");
XMPPConnection connection = new XMPPTCPConnection(config);
try {
connection.connect();
connection.login("USERNAME", "PASSWORD");
// Assume we've created a XMPPConnection name "connection"._
ChatManager chatmanager = ChatManager.getInstanceFor(connection);
Chat newChat = chatmanager.createChat("neilneil@jabb3r.org", new MessageListener() {
public void processMessage(Chat chat, Message message) {
System.out.println("Received message: " + message);
}
});
try {
newChat.sendMessage("Howdy!");
}
catch (XMPPException e) {
System.out.println("Error Delivering block");
}
// ConnectionException.getFailedAddresses();
} catch …Run Code Online (Sandbox Code Playgroud)