There seems to be a bit of an issue with the Roster defaulting to SUBSCRIPTION_ACCEPT_ALL if you are writing a program that must manually handle subscriptions. Let me explain:
- If you are offline and another user sends you a subscription request, as soon as you login using Smack that subscription is accepted…even if you set the subscription mode to manual right after login. This appears to be a result of the Roster defaulting to SUBSCRIPTION_ACCEPT_ALL.
Here is the code I’'m using to isolate & test this:
public class TestLogin
{
public TestLogin()
{
try
{
XMPPConnection con = new XMPPConnection(“myserver”);
con.login(“username”, “password”);
Roster roster = con.getRoster();
roster.setSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
con.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public static void main(String[] args)
{
TestLogin testLogin = new TestLogin();
System.out.println(“Done test”);
}
}
Has anyone else experienced this or is there something else I should be doing? My current solution is that I’'ll just rebuild smack.jar with a Roster that defaults to SUBSCRIPTION_MANUAL.
Thanks,
Brodie