Skip to content

Commit 214c8b2

Browse files
EDU-1942: Addresses AI review
1 parent 80df868 commit 214c8b2

File tree

1 file changed

+70
-7
lines changed

1 file changed

+70
-7
lines changed

README.md

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
![Ably Pub/Sub Java Header](images/javaSDK-github.png)
2-
3-
[![version: 0.3.0](https://img.shields.io/badge/version-0.3.0-2ea44f)](https://github.com/ably/ably-java/releases/tag/v0.3.0)
2+
[![Latest Version](https://img.shields.io/maven-central/v/io.ably/ably-java)](https://central.sonatype.com/artifact/io.ably/ably-java)
43
[![License](https://badgen.net/github/license/ably/ably-java)](https://github.com/ably/ably-java/blob/main/LICENSE)
54

65
# Ably Pub/Sub Java SDK
@@ -11,8 +10,8 @@ Ably Pub/Sub provides flexible APIs that deliver features such as pub-sub messag
1110

1211
Find out more:
1312

14-
* [Ably Pub/Sub docs](https://ably.com/docs/basics)
15-
* [Ably Pub/Sub examples](https://ably.com/examples?product=pubsub)
13+
* [Ably Pub/Sub docs.](https://ably.com/docs/basics)
14+
* [Ably Pub/Sub examples.](https://ably.com/examples?product=pubsub)
1615

1716
---
1817

@@ -21,6 +20,7 @@ Find out more:
2120
Everything you need to get started with Ably:
2221

2322
- [Quickstart in Pub/Sub using Java](https://ably.com/docs/getting-started/quickstart?lang=java)
23+
* [SDK Setup for Java.](https://ably.com/docs/getting-started/setup?lang=java)
2424

2525
---
2626

@@ -33,14 +33,77 @@ The following platforms are supported:
3333
| Platform | Support |
3434
|----------|---------|
3535
| Java | >= 1.8 (JRE 8 or later) |
36-
| Kotlin | All versions (>= 0.0.1 supported), but we recommend >= 1.8 for best compatibilit. |
36+
| Kotlin | All versions (>= 1.0 supported), but we recommend >= 1.8 for best compatibility. |
3737
| Android | >=4.4 (API level 19) |
3838

3939
> [!IMPORTANT]
4040
> SDK versions < 1.2.35 will be [deprecated](https://ably.com/docs/platform/deprecate/protocol-v1) from November 1, 2025.
4141
4242
---
4343

44+
## Installation
45+
46+
The Java SDK is available as a [Maven dependency](https://mvnrepository.com/artifact/io.ably/ably-java). To get started with your project, install the package:
47+
48+
### Install for Maven:
49+
50+
```xml
51+
<dependency>
52+
<groupId>io.ably</groupId>
53+
<artifactId>ably-java</artifactId>
54+
<version>1.2.22</version>
55+
</dependency>
56+
```
57+
58+
### Install for Gradle:
59+
60+
```gradle
61+
implementation 'io.ably:ably-java:1.2.22'
62+
implementation 'org.slf4j:slf4j-simple:2.0.7'
63+
```
64+
65+
Run the following to instantiate a client:
66+
67+
```java
68+
import io.ably.lib.realtime.AblyRealtime;
69+
import io.ably.lib.types.ClientOptions;
70+
71+
ClientOptions options = new ClientOptions(apiKey);
72+
AblyRealtime realtime = new AblyRealtime(options);
73+
```
74+
75+
---
76+
77+
## Usage
78+
79+
The following code connects to Ably's realtime messaging service, subscribes to a channel to receive messages, and publishes a test message to that same channel.
80+
81+
82+
```java
83+
// Initialize Ably Realtime client
84+
ClientOptions options = new ClientOptions("your-ably-api-key");
85+
options.clientId = "me";
86+
AblyRealtime realtimeClient = new AblyRealtime(options);
87+
88+
// Wait for connection to be established
89+
realtimeClient.connection.on(ConnectionEvent.connected, connectionStateChange -> {
90+
System.out.println("Connected to Ably");
91+
92+
// Get a reference to the 'test-channel' channel
93+
Channel channel = realtimeClient.channels.get("test-channel");
94+
95+
// Subscribe to all messages published to this channel
96+
channel.subscribe(message -> {
97+
System.out.println("Received message: " + message.data);
98+
});
99+
100+
// Publish a test message to the channel
101+
channel.publish("test-event", "hello world");
102+
});
103+
```
104+
---
105+
106+
44107
## Proxy support
45108

46109
You can add proxy support to the Ably Java SDK by configuring `ProxyOptions` in your client setup, enabling connectivity through corporate firewalls and secured networks.
@@ -111,10 +174,10 @@ Read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines to contribute to Ably.
111174

112175
## Releases
113176

114-
The [CHANGELOG.md](/ably/ably-js/blob/main/CHANGELOG.md) contains details of the latest releases for this SDK. You can also view all Ably releases on [changelog.ably.com](https://changelog.ably.com).
177+
The [CHANGELOG.md](/ably/ably-java/blob/main/CHANGELOG.md) contains details of the latest releases for this SDK. You can also view all Ably releases on [changelog.ably.com](https://changelog.ably.com).
115178

116179
---
117180

118-
## Support, Feedback, and Troubleshooting
181+
## Support, feedback, and troubleshooting
119182

120183
For help or technical support, visit Ably's [support page](https://ably.com/support) or [GitHub Issues](https://github.com/ably/ably-java/issues) for community-reported bugs and discussions.

0 commit comments

Comments
 (0)