You should explicitly enable OriginManager to use it. This can be done by two ways:
-
Using
#enableOriginManager()method:pubnub.enableOriginManager();
-
Using
#setOriginsPool()method. Second parameter should be true.pubnub.setOriginsPool(new String(){"origin1", "origin2"}, true);
To explicitly disable OriginManager use #disableOriginManager() method:
pubnub.disableOriginManager();Origins pool is implemented as LinkedHashSet, so sequence order is important. At least 2 origins should be specified, otherwise PubnubError will be thrown. Use #setOriginsPool() method for this purpose:
-
setup using
Stringarray:pubnub.setOriginsPool(new String[]{"origin1", "origin2"});
-
or using
LinkedHashSet:LinkedHashSet originsPool = new LinkedHashSet(); originsPool.add("origins1"); originsPool.add("origins2"); pubnub.setOriginsPool(originsPool);
To be able to handle OriginManager errors, happened while OriginManager working, pass in Callback instance to #enableOriginManager() method:
pubnub.enableOriginManager(new Callback() {
@Override
public void errorCallback(String channel, PubnubError error) {
// handle PubnubError
}
});If OriginManager cannot be enabled, error callback will be triggered.
OriginManager has also a few default configs that can be overridden:
// default 5
pubnub.setOriginManagerInterval(60);
// default 5
pubnub.setOriginManagerIntervalAfterFailure(30);
// default 5
pubnub.setOriginManagerMaxRetries(10);