Skip to content

Commit eb0d161

Browse files
authored
Merge pull request #147 from pusher/always-specify-cluster
Always specify cluster when instantiating pusher
2 parents 5d706a7 + 1243d7c commit eb0d161

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ Here's the API in a nutshell.
7878

7979
```java
8080
// Create a new Pusher instance
81-
Pusher pusher = new Pusher(YOUR_APP_KEY);
81+
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
82+
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
8283

8384
pusher.connect(new ConnectionEventListener() {
8485
@Override
@@ -120,32 +121,28 @@ More information in reference format can be found below.
120121
The standard constructor take an application key which you can get from the app's API Access section in the Pusher dashboard.
121122

122123
```java
123-
Pusher pusher = new Pusher(YOUR_APP_KEY);
124+
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
125+
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
124126
```
125127

126128
If you are going to use [private](http://pusher.com/docs/private_channels) or [presence](http://pusher.com/docs/presence_channels) channels then you will need to provide an `Authorizer` to be used when authenticating subscriptions. In order to do this you need to pass in a `PusherOptions` object which has had an `Authorizer` set.
127129

128130
```java
129131
HttpAuthorizer authorizer = new HttpAuthorizer("http://example.com/some_auth_endpoint");
130-
PusherOptions options = new PusherOptions().setAuthorizer(authorizer);
132+
PusherOptions options = new PusherOptions().setCluster(YOUR_APP_CLUSTER).setAuthorizer(authorizer);
131133
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
132134
```
133135

134136
See the documentation on [Authenticating Users](http://pusher.com/docs/authenticating_users) for more information.
135137

136-
You can also specify the Pusher cluster you wish to connect to on the PusherOptions, e.g.
137-
138-
```java
139-
options.setCluster("eu");
140-
```
141-
142138
If you need finer control over the endpoint then the setHost, setWsPort and setWssPort methods can be employed.
143139
## Connecting
144140

145141
In order to send and receive messages you need to connect to Pusher.
146142

147143
```java
148-
Pusher pusher = new Pusher(YOUR_APP_KEY);
144+
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
145+
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
149146
pusher.connect();
150147
```
151148

@@ -168,7 +165,8 @@ After disconnection the Pusher instance will release any internally allocated re
168165
Implement the `ConnectionEventListener` interface to receive connection state change events:
169166

170167
```java
171-
Pusher pusher = new Pusher(YOUR_APP_KEY);
168+
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
169+
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
172170
pusher.connect(new ConnectionEventListener() {
173171
@Override
174172
public void onConnectionStateChange(ConnectionStateChange change) {

0 commit comments

Comments
 (0)