嗨,我正在使用smack.jar.I我能够使用它连接gtalk.使用Roster.getentries()
我可以得到我的好友列表.但我怎么能添加新朋友到我的buddyList.Is有任何API smack暴露添加新用户?
谢谢
此问题类似于:使用authToken对Google Talk(XMPP,Smack)进行身份验证
我有android.accounts.AccountManager类及其获取Google帐户身份验证令牌的方法:
public AccountManagerFuture<Bundle> getAuthToken (Account account,
String authTokenType, Bundle options, Activity activity,
AccountManagerCallback<Bundle> callback, Handler handler)
Run Code Online (Sandbox Code Playgroud)我知道如何准备身份验证XML:
jidAndToken ="\0" + UTF8(YOURUSERNAME@gmail.com) + "\0" + Auth
Run Code Online (Sandbox Code Playgroud)
(其中"\ 0"旨在是一个值为零的单个八位字节).在最初的SASL auth中使用它:
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
mechanism='X-GOOGLE-TOKEN'>Base64(jidAndToken)</auth>
Run Code Online (Sandbox Code Playgroud)但是我无法将其与Smack API集成,就像有人在Facebook聊天一样:XMPP与Java Asmack库支持X-FACEBOOK-PLATFORM
有人能帮我吗?
我在我的Android应用程序中使用以下代码:
Thread d = new Thread(new Runnable() {
@Override
public void run() {
SmackConfiguration.setDefaultPacketReplyTimeout(10000);
XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword("admin", "password")
.setServiceName("192.168.0.200")
.setHost("192.168.0.200")
.setPort(5223).setSecurityMode(SecurityMode.ifpossible)
.build();
AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);
try {
conn2.connect();
conn2.login();
Presence presence = new Presence(Presence.Type.unavailable);
presence.setStatus("Gone fishing");
// Send the packet (assume we have an XMPPConnection instance called "con").
conn2.sendStanza(presence);
} catch (SmackException | IOException | XMPPException e) {
e.printStackTrace();
Log.d("TAG", e.toString());
}
ChatManager chatmanager = ChatManager.getInstanceFor(conn2);
Chat newChat = chatmanager.createChat("harsh@192.168.0.200");
try {
newChat.sendMessage("Howdy!");
}
catch (NotConnectedException …
Run Code Online (Sandbox Code Playgroud) 在Openfire服务器中安装Open Archive插件后,我可以看到来自openfire管理面板的两个用户之间的聊天对话非常简单,也是基于网络的.现在我想从我使用Smack库的聊天客户端应用程序(用java编写)中检索那些对话或聊天记录.我没有找到任何有用的资源.任何建议都会有所帮助.
我正在使用Smack在Java/Spark中开发内部仪表板,以便在LDAP用户组之间启动Google Talk会议.我跑的时候
MultiUserChat.isServiceEnabled(connection, "user@mydomain.com")
Run Code Online (Sandbox Code Playgroud)
它返回false.我知道通过GMail客户端,可以开始群组对话.由于Google Apps域中存在某些内容,或Google是否在Google Talk中使用其他方式进行群聊,这可能会导致错误吗?
嗨有任何方法可以做android xmpp客户端,它将能够获得消息接收确认(XEP-0184)我读到有XEP-0184在smack但正常smack不能与android(或我不能这样做) )总有SASL身份验证异常.
我想阻止聊天列表中的某位朋友XMPP
.代码工作正常.没有例外,但我无法阻止用户.我正在使用开火服务器.我应该在服务器上做些什么改变?
你们有什么想法吗?
我的代码:
public void XMPPAddNewPrivacyList(Connection connection, String userName) {
String listName = "newList";
// Create the list of PrivacyItem that will allow or
// deny some privacy aspect
List<PrivacyItem> privacyItems = new Vector<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.toString(),
false, 1);
item.setValue(userName);
privacyItems.add(item);
// Create the new list.
try {
PrivacyListManager privacyManager = new PrivacyListManager(connection);
privacyManager = PrivacyListManager
.getInstanceFor(connection);
privacyManager.createPrivacyList(listName, privacyItems);
} catch (XMPPException e) {
System.out.println("PRIVACY_ERROR: " + e);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Smack和Openfire服务器作为聊天客户端,所有工作都很好,比如聊天,发送新用户的邀请,获取可用用户列表等等.我不知道如果连接是什么怎么办在粘性服务中我添加了一个连接监听器连接和连接断开连接,让我们说"Internet连接"
我正在使用以下代码作为connectionlistener.
connection.addConnectionListener(new ConnectionListener() {
@Override
public void reconnectionSuccessful() {
Log.i("","Successfully reconnected to the XMPP server.");
}
@Override
public void reconnectionFailed(Exception arg0) {
Log.i("","Failed to reconnect to the XMPP server.");
}
@Override
public void reconnectingIn(int seconds) {
Log.i("","Reconnecting in " + seconds + " seconds.");
}
@Override
public void connectionClosedOnError(Exception arg0) {
Log.i("","Connection to XMPP server was lost.");
Log.v("ONMESSAGE", "Error was " + arg0.toString() + "and Now connecting");
}
@Override
public void connectionClosed() {
Log.i("","XMPP connection was closed.");
}
}); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用getMembers()获取成员列表但我得到'错误代码:403,forbidden-auth'试图获取成员列表的用户是一个组的成员但是如果我做的话所有者的相同操作,他可以成功获得一个列表.
这是我获取成员列表的配置 'muc#roomconfig_getmemberlist' : [moderator, participants, visitor]
并且在xep-045中也非常清楚地提到"服务应该也应该将成员列表返回给仅限成员的房间中的任何占用者;即,当房间中的成员请求成员列表时,它不应该产生错误."
那我在这里缺少什么?
这些是捕获数据包
SENT(0):
<iq to='membersonlygroup@muc.domain' from='92123456@domain/Resource' id='1BO5n-74' type='get'><query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='member'></item></query></iq>
Run Code Online (Sandbox Code Playgroud)
SMACK:RECV(0):
`<iq from='membersonlygroup@muc.domain' to='92123456@domain/Resource' id='1BO5n-74' type='error'><query xmlns='http://jabber.org/protocol/muc#admin'><item affiliation='member'/></query><error code='403' type='auth'><forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Administrator privileges required</text></error></iq><r xmlns='urn:xmpp:sm:3'/>`
Run Code Online (Sandbox Code Playgroud)
编辑:还有 一件事是成员有参与者的角色,但我注意到在这种情况下角色值为空.
我正在开发一个带有SMACK库的Android上的即时消息应用程序,它使用OPENFIRE作为xmpp服务器.我想从MONFCORING SERVICE插件(基于XEP-0313)启用的openfire服务器中的MessageArchiveManager获取每个会话的最后一条消息.我知道mamManager.queryArchive()可以获取与特定jid相关的消息,或者可以获取服务器中存在的特定数量的消息(没有自定义的sepration),但我们认为smack不知道哪些JID有对话服务器!一个解决方案是每个ROSTER条目发送请求,但是当它包含大量联系人时,它的成本很高,而且我们可能会与Roster中的任何人进行对话.有没有办法或插件或其他扩展来做到这一点?
smack ×10
xmpp ×9
android ×5
java ×2
openfire ×2
archiving ×1
asmack ×1
google-apps ×1
google-talk ×1
mongoose-im ×1
timeout ×1