Skip to content

Latest commit

 

History

History
71 lines (49 loc) · 1.68 KB

File metadata and controls

71 lines (49 loc) · 1.68 KB

Origin Manager

How to enable/disable

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

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 String array:

    pubnub.setOriginsPool(new String[]{"origin1", "origin2"});
  • or using LinkedHashSet:

    LinkedHashSet originsPool = new LinkedHashSet();
    
    originsPool.add("origins1");
    originsPool.add("origins2");
    
    pubnub.setOriginsPool(originsPool);

Errors callback

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.

Configs

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);