Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Here's the API in a nutshell.

```java
// Create a new Pusher instance
Pusher pusher = new Pusher(YOUR_APP_KEY);
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
Pusher pusher = new Pusher(YOUR_APP_KEY, options);

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

```java
Pusher pusher = new Pusher(YOUR_APP_KEY);
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
```

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.

```java
HttpAuthorizer authorizer = new HttpAuthorizer("http://example.com/some_auth_endpoint");
PusherOptions options = new PusherOptions().setAuthorizer(authorizer);
PusherOptions options = new PusherOptions().setCluster(YOUR_APP_CLUSTER).setAuthorizer(authorizer);
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
```

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

You can also specify the Pusher cluster you wish to connect to on the PusherOptions, e.g.

```java
options.setCluster("eu");
```

If you need finer control over the endpoint then the setHost, setWsPort and setWssPort methods can be employed.
## Connecting

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

```java
Pusher pusher = new Pusher(YOUR_APP_KEY);
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
pusher.connect();
```

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

```java
Pusher pusher = new Pusher(YOUR_APP_KEY);
PusherOption options = new PusherOptions().setCluster(YOUR_APP_CLUSTER);
Pusher pusher = new Pusher(YOUR_APP_KEY, options);
pusher.connect(new ConnectionEventListener() {
@Override
public void onConnectionStateChange(ConnectionStateChange change) {
Expand Down