diff --git a/content/root/quick-start-guide.textile b/content/root/quick-start-guide.textile index 321f332080..ce3f8abf11 100644 --- a/content/root/quick-start-guide.textile +++ b/content/root/quick-start-guide.textile @@ -93,20 +93,32 @@ blang[php]. bc[php]. require_once __DIR__ . '/../vendor/autoload.php'; blang[java]. - The Ably Client Library SDK is hosted on "GitHub":https://github.com/ably/ably-java. + The Ably Client Library SDK is available on "GitHub":https://github.com/ably/ably-java and hosted on "Maven Central":https://mvnrepository.com/repos/central. - To get started with your project, add the SDK into your @build.gradle@ dependencies section. + To get started with your project, add the SDK into your @build.gradle@ dependencies section and a reference to Maven in the repositories section if it isn't included by default. For Java applications: ```[java] - compile 'io.ably:ably-java:1.2.0' + dependencies { + implementation 'io.ably:ably-java:1.2.0' + } + + repositories { + mavenCentral() + } ``` For Android apps: ```[java] - compile 'io.ably:ably-android:1.2.0' + dependencies { + implementation 'io.ably:ably-android:1.2.0' + } + + repositories { + mavenCentral() + } ``` *Note*: In the above examples a specific version of the SDK is referenced. Ably recommends that you always use the latest stable version available for "Java":https://bintray.com/ably-io/ably/ably-java and "Android":https://bintray.com/ably-io/ably/ably-android. @@ -211,10 +223,10 @@ ably.connection.on('connected', function() { bc[java]. ClientOptions options = new ClientOptions("{{API_KEY}}"); AblyRealtime ably = new AblyRealtime(options); -ably.connection.on(ConnectionState.connected, new ConnectionStateListener() +ably.connection.on(ConnectionState.connected, new ConnectionStateListener() { @Override public void onConnectionStateChanged(ConnectionStateChange state) { - System.out.println("New state is " + change.current.name()); + System.out.println("New state is " + state.current.name()); switch (state.current) { case connected: { // Successful connection @@ -303,13 +315,12 @@ blang[python,php]. ```[java] Channel channel = ably.channels.get("quickstart"); - channel.subscribe(new MessageListener() { + channel.subscribe("greeting", new Channel.MessageListener() { @Override public void onMessage(Message message) { System.out.println("Received a greeting message in realtime: " + message.data); } }); - channel.publish("example", "message data"); ``` bc[swift]. let channel = ably.channels.get("quickstart") @@ -343,8 +354,17 @@ The following example code publishes a message to the @quickstart@ channel with bc[jsall](code-editor:quick-start-guide/send-message). var channel = ably.channels.get('quickstart'); channel.publish('greeting', 'hello!'); -bc[java]. Channel channel = ably.channels.get('quickstart'); -channel.publish('greeting', 'hello!'); +bc[java]. Channel channel = ably.channels.get("quickstart"); +channel.publish("greeting", "hello", new CompletionListener() { + @Override + public void onSuccess() { + System.out.println("Message sent"); + } + @Override + public void onError(ErrorInfo reason) { + System.out.println("Message not sent, error occurred: " + reason.message); + } +}); bc[csharp]. var channel = ably.Channels.Get("quickstart"); channel.Publish("greeting", "hello!"); @@ -399,10 +419,10 @@ ably.connection.on('closed', function() { }); bc[java]. ably.connection.close(); -ably.connection.on(ConnectionState.closed, new ConnectionStateListener() +ably.connection.on(ConnectionState.closed, new ConnectionStateListener() { @Override public void onConnectionStateChanged(ConnectionStateChange state) { - System.out.println("New state is " + change.current.name()); + System.out.println("New state is " + state.current.name()); switch (state.current) { case closed: { // Connection closed