[英]How to send and receive friend request to XMPP server using smack Api
How to send and receive friend request in android using SMACK API.I know to add user to roster i can use roster.createEntry("abcd@203.xxx.xx.xx", "abcd", null); 如何使用SMACK API在Android中发送和接收朋友请求。我知道将用户添加到名册中,我可以使用roster.createEntry(“ abcd@203.xxx.xx.xx”,“ abcd”,null); but i want to ask to user if he/she wants to add me to their roster or not.How to achieve this?
但是我想问用户他/她是否想将我添加到他们的名单中。如何实现这一目标?
Instead of creating a Roster, just send him/her a presence, with the subscribe type, then when he/she receives the subscribe presence, you show the Accept/Decline dialog. 无需创建名册,只需向他/她发送具有订阅类型的状态,然后当他/她收到订阅状态时,将显示“接受/拒绝”对话框。 If he/she accepts, then he/she sends back a subscribed type presence and also a subscribe type presence and creates a roster(it is needed to set the rosters name).
如果他/她接受,那么他/她将发回订阅类型的状态和订阅类型的状态,并创建一个名册(需要设置名册名称)。 Now the user who initially sent the subscribe, receives a subscribed and a subscribe type presence from the user he/she added as a friend.
现在,最初发送订阅的用户从他/她添加为朋友的用户那里收到订阅和订阅类型的状态。 Receiving these, he/she sends back automatically a subscribed type presence and creates a roster.
接收到这些信息后,他/她会自动发送回已订阅类型的状态并创建花名册。
Simpler way: 更简单的方法:
User1 ----subscribe---> User2
show dialog
if accept
User2 ----subscribed---> User1
User2 ----subscribe---> User1
create roster with name(which is actually modifying the roster, since the subscribe creates one, without a name)
without dialog
User1 ----subscribed---> User2
create roster with name(which is actually modifying the roster, since the subscribe creates one, without a name)
end if
else
User2 ----unsubscribed---> User1
User1 delete roster
end else
Hope this helped. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.