how to add roster with subscription mode “both”

前端 未结 5 1403
失恋的感觉
失恋的感觉 2020-12-24 03:40

i\'m using smack 3.1.0, and when i add a roster,i can\'t get subscription \"both\". who can help me? below is my code:

Roster.setDefaultSubscriptionMode(Rost         


        
5条回答
  •  别那么骄傲
    2020-12-24 03:50

    Rewriting @mschonaker's answer to be a little more clear.

    Both users need to subscribe to each other and accept the subscription request they received. Let's call them Alice and Bob. Alice sends a subscription request to Bob:

    Presence subscribe = new Presence(Presence.Type.subscribe);
    subscribe.setTo('bob@example.com');
    connection.sendPacket(subscribe);
    

    When Bob receives the request, he approves it:

    Presence subscribed = new Presence(Presence.Type.subscribed);
    subscribed.setTo('alice@example.com');
    connection.sendPacket(subscribed);
    

    Bob may also be interested in Alice's presence, so he subscribes to her:

    Presence subscribe = new Presence(Presence.Type.subscribe);
    subscribe.setTo('alice@example.com');
    connection.sendPacket(subscribe);
    

    And Alice needs to approve Bob's request:

    Presence subscribed = new Presence(Presence.Type.subscribed);
    subscribed.setTo('bob@example.com');
    connection.sendPacket(subscribed);
    

    Section 3.1 of RFC6121 is the current best reference for how this works.

提交回复
热议问题