使用 (a)smack 检查 XMPP 中的服务器上是否存在用户

编程入门 行业动态 更新时间:2024-10-24 19:29:28
本文介绍了使用 (a)smack 检查 XMPP 中的服务器上是否存在用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 asmack 作为库并在 android 平台上开发聊天应用程序.有什么办法可以在添加好友之前先查看服务器上是否存在该好友?

I'm working on a chat application using asmack as a library and on android platform. Is there is any way that before adding friend in Roster can I check that friend exist on server or not?

推荐答案

我找到了答案:

UserSearchManager search = new UserSearchManager(mXMPPConnection); Form searchForm = search .getSearchForm("search." + mXMPPConnection.getServiceName()); Form answerForm = searchForm.createAnswerForm(); answerForm.setAnswer("Username", true); answerForm.setAnswer("search", user); ReportedData data = search .getSearchResults(answerForm, "search." + mXMPPConnection.getServiceName()); if (data.getRows() != null) { for (ReportedData.Row row: data.getRows()) { for (String value: row.getValues("jid")) { Log.i("Iteartor values......", " " + value); } } Toast.makeText(_service, "Username Exists", Toast.LENGTH_SHORT).show(); }

如果服务器没有任何指定名称的输入,则 Itearator 它没有值并且代码不会进入 while(it.hasNext)..

if Server has not any entery with that specified name then Itearator it has no value and code will not go inside while(it.hasNext)..

更多推荐

使用 (a)smack 检查 XMPP 中的服务器上是否存在用户

本文发布于:2023-06-10 22:55:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/620839.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否存在   器上   用户   smack   XMPP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!