Skip to content

Commit 548e4f4

Browse files
committed
Update OriginManager.md
1 parent 7e0bd29 commit 548e4f4

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

‎java/OriginManager.md‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,71 @@
11
# Origin Manager
2+
3+
## How to enable/disable
4+
5+
You should explicitly enable OriginManager to use it. This can be done by two ways:
6+
7+
* Using `#enableOriginManager()` method:
8+
``` java
9+
pubnub.enableOriginManager();
10+
```
11+
12+
* Using `#setOriginsPool()` method. Second parameter should be true.
13+
14+
``` java
15+
pubnub.setOriginsPool(new String(){"origin1", "origin2"}, true);
16+
```
17+
18+
To explicitly disable OriginManager use `#disableOriginManager()` method:
19+
20+
``` java
21+
pubnub.disableOriginManager();
22+
```
23+
24+
## Origins pool
25+
26+
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:
27+
28+
* setup using `String` array:
29+
30+
``` java
31+
pubnub.setOriginsPool(new String[]{"origin1", "origin2"});
32+
```
33+
34+
* or using `LinkedHashSet`:
35+
36+
``` java
37+
LinkedHashSet originsPool = new LinkedHashSet();
38+
39+
originsPool.add("origins1");
40+
originsPool.add("origins2");
41+
42+
pubnub.setOriginsPool(originsPool);
43+
```
44+
45+
## Errors callback
46+
To be able to handle OriginManager errors, happened while OriginManager working, pass in `Callback` instance to `#enableOriginManager()` method:
47+
48+
``` java
49+
pubnub.enableOriginManager(new Callback() {
50+
@Override
51+
public void errorCallback(String channel, PubnubError error) {
52+
// handle PubnubError
53+
}
54+
});
55+
```
56+
57+
If OriginManager cannot be enabled, `error` callback will be triggered.
58+
59+
## Configs
60+
OriginManager has also a few default configs that can be overridden:
61+
62+
```java
63+
// default 5
64+
pubnub.setOriginManagerInterval(60);
65+
66+
// default 5
67+
pubnub.setOriginManagerIntervalAfterFailure(30);
68+
69+
// default 5
70+
pubnub.setOriginManagerMaxRetries(10);
71+
```

0 commit comments

Comments
 (0)