Logout to add a friend in xmpp smack

后端 未结 1 1464
孤城傲影
孤城傲影 2021-01-15 17:56

In my application when I have to add a friend I usually do send subscription packets 4 times i.e

A->B (subscribe) B->A ( subscribed) B-A( subscribe) A->B ( subscribe

相关标签:
1条回答
  • 2021-01-15 18:24

    For sending a request you have to use,

    roster.createEntry("mail_id", null, null);
    

    And for Listening the Request you have to listen using PacketListener. And check the Presence

    Presence presence = (Presence) packet;
    Presence presence_request = new Presence(Presence.Type.subscribed);
    presence_request.setTo(presence.getFrom());
    presence_request.setType(Presence.Type.subscribed);
    presence_request.setFrom("current_logged_in_user");
    connection.sendPacket(presence_request);
    roster.createEntry(presence.getFrom(), null, null);
    
    0 讨论(0)
提交回复
热议问题