powered by Jive Software

Handling subscribtions

I have this piece of code:

connection = new XMPPConnection(host);

connection.login(user, password, resource);

connection.getRoster().setSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);

When I send a subscription request, I get a Presence packet, for which I just print out something and ignore it (since I’'m still testing this).

When I then reconnect, the request is immediately authorized, before the subscription mode is set.

How can I change this?

Bart,

I’‘ll create an issue at Jira (issue tracker) requesting this change. Unfortunately, I can’‘t think of an easy workaround for you so you’'ll have to wait for the next release which we are planning to have soon (this year).

Thanks,

– Gato

Thanks Gato.

I was thinking of using a static public var instead of a setting, which could then be set before the connection is made.

Bart,

You are right. That’'s an alternative we still have to discuss. I think that the static var option is a very easy thing to do but the down side of this option is that 1) a static var implies that all the instances will share the same value and 2) we could potentially end up, in the future, with many static vars if we apply this pattern of solution whenever we need to parameterize.

Note: I realized of these two cons when I implemented the possibility to configure the XMPPConnection timeout.

Other alternatives I can think of are:

  1. be able to access the roster (before you login) so you will be able to set the subscription mode.

  2. hold in SmackConfiguration (new class) configurations for a certain set of classes. In our example, we’'ll need to hold in SmackConfiguration the configuration for the Roster class. This option is similar to the static var option but avoids the “proliferation” of static vars across the system.

  3. be able to provide for each connection a configuration where in this case we could specify the subscription mode value.

Regards,

– Gato