发送/接收好友请求在Android中使用XMPP服务器

时间:2021-12-01 18:14:37

I am creating a application based on XMPP chat Messenger. Now we have some customize feature needs to be implement in the app like Send/Receive friend request within the messenger. How we can do that .Please help with your suggestions.

我正在创建一个基于XMPP聊天Messenger的应用程序。现在我们需要在应用程序中实现一些自定义功能,例如在Messenger中发送/接收好友请求。我们如何做到这一点。请帮助您的建议。

roster = _connection.getRoster();
roster.createEntry(userID, nickname, null);

Currently we are using this method but it directly added the contact in my messenger contact list. Now what I want is to ask if any new friend request comes like BBM(Blackberry Messenger). then it should ask for confirmation before adding directly to contact lists it is happening currently.

目前我们正在使用此方法,但它直接在我的信使联系人列表中添加了联系人。现在我想要的是询问是否有任何新的朋友请求像BBM(Blackberry Messenger)。然后它应该要求确认,然后直接添加到当前正在发生的联系人列表。

Please help asap.

请尽快帮忙。

2 个解决方案

#1


0  

I can help you out. I have fully functional messaging app. I assume you are using Smack or Asmack as the XMPP library.

我可以帮你。我有功能齐全的消息应用程序。我假设你使用Smack或Asmack作为XMPP库。

Adding a friend

添加好友

Presence request = new Presence(Presence.Type.subscribe);
        packet.setTo("john@ejabberd.org");
        mXMPPConnection.sendPacket(packet);

Accepting a request

接受请求

Presence accept = new Presence(Presence.Type.subscribed);
                    accept.setTo("john@ejabberd.org");
                    mXMPPConnection.sendPacket(accept);

Ask me if you need anything else :) Cheers

问我是否还需要别的东西:)干杯

#2


0  

Send Friend Request/Invitation [user1@domain],

发送朋友请求/邀请[user1 @ domain],

Presence presence = new Presence(Presence.Type.subscribe);
presence.setTo("user2@domain");
connection.sendStanza(presence);

Accept Friend Request/Invitation [user2@domain],

接受朋友请求/邀请[user2 @ domain],

Presence presence = new Presence(Presence.Type.subscribed);
presence.setTo("user1@domain.com");
connection.sendStanza(presence);

Every time user2 will login, server will send the subscribe presence packets to user2 until user2 send any response against the request.

每次user2登录时,服务器都会将订阅在线状态数据包发送给user2,直到user2针对请求发送任何响应。

#1


0  

I can help you out. I have fully functional messaging app. I assume you are using Smack or Asmack as the XMPP library.

我可以帮你。我有功能齐全的消息应用程序。我假设你使用Smack或Asmack作为XMPP库。

Adding a friend

添加好友

Presence request = new Presence(Presence.Type.subscribe);
        packet.setTo("john@ejabberd.org");
        mXMPPConnection.sendPacket(packet);

Accepting a request

接受请求

Presence accept = new Presence(Presence.Type.subscribed);
                    accept.setTo("john@ejabberd.org");
                    mXMPPConnection.sendPacket(accept);

Ask me if you need anything else :) Cheers

问我是否还需要别的东西:)干杯

#2


0  

Send Friend Request/Invitation [user1@domain],

发送朋友请求/邀请[user1 @ domain],

Presence presence = new Presence(Presence.Type.subscribe);
presence.setTo("user2@domain");
connection.sendStanza(presence);

Accept Friend Request/Invitation [user2@domain],

接受朋友请求/邀请[user2 @ domain],

Presence presence = new Presence(Presence.Type.subscribed);
presence.setTo("user1@domain.com");
connection.sendStanza(presence);

Every time user2 will login, server will send the subscribe presence packets to user2 until user2 send any response against the request.

每次user2登录时,服务器都会将订阅在线状态数据包发送给user2,直到user2针对请求发送任何响应。