From 1243d7c74a4bcb947b8c8b468a0a01e4a55ec082 Mon Sep 17 00:00:00 2001 From: James Lees Date: Mon, 12 Jun 2017 10:31:00 +0100 Subject: [PATCH] Always specify cluster when instantiating pusher --- README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5a2f5f38..65a8a1a9 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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(); ``` @@ -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) {