<commit_before># Cogswell.ioPub/Sub SDK

- [`PubSubSDK`](#pubsubsdk)
  - [`getInstance()`](#getinstance)
  - [`connect (keys)`](#connect-keys)
- [`PubSubOptions`](#pubsuboptions)
  - [`new PubSubOptions()`](#new-pubsuboptions)
  - [`new PubSubOptions (url, isAutoReconnect, connectTimeoutMs, sessionUuid)`](#new-pubsuboptions-isautoreconnect-connecttimeoutms-sessionUuid)
- [`PubSubHandle`](#pubsubhandle)
  - [`getSessionUuid()`](#setsessionuuid)
  - [`subscribe (channel, handler)`](#subscribe-channel-handler)
  - [`unsubscribe (channel)`](#unsubscribe-channel)
  - [`unsubscribeAll()`](#unsubscribeall)
  - [`listSubscriptions()`](#listsubscriptions)
  - [`publish (channel, message)`](#publish-channel-message)
  - [`publishWithAck (channel, message)`](#publishwithack-channel-message)
  - [`close()`](#close)
- [A complete example](#a-complete-example)
- [Running the tests](#running-the-tests)

## Code Examples

The code examples that follow illustrate the individual methods of the Android
Cogswell.ioPub/Sub SDK. The examples illustrate only how the methods might be
used. For more information, including complete method signatures and possible
errors, see the documentation at [the Cogswell.ioPub/Sub website](https://cogswell.io/docs/android/client-sdk/api/).

To support versions of Android as old as API level 15, this SDK uses the [Guava](https://github/google/guava) library for async calls.

A complete example, illustrating how the methods can be used
together, is provided at the end of this document.

### [`PubSubSDK`](#pubsubsdk)

#### [`getInstance()`](#getinstance)
You can use the `getInstance` method to get a reference to the sdk.
```java
PubSubSDK sdk = PubSubSDK.getInstance();
```

#### [`connect (keys)`](#connect-keys)
You'll need to get your the from your Cogswell.io pub/sub account.
```java
List<String> keys = new ArrayList<String>();
keys.add("A-*-*");
keys.add("R-*-*");
keys.add("W-*-*");
```

```java
ListenableFuture<PubSubHandle> connectFuture = PubSubSDK.getInstance().connect(keys);

Futures.addCallback(connectFuture, new FutureCallback<PubSubHandle>() {
    public void onSuccess(PubSubHandle psh) {
        Log.e("TEST","Connected");
    }<commit_msg>PUB-81 Added link to complete example<commit_after># Cogswell.ioPub/Sub SDK

- [`PubSubSDK`](#pubsubsdk)
  - [`getInstance()`](#getinstance)
  - [`connect (keys)`](#connect-keys)
- [`PubSubOptions`](#pubsuboptions)
  - [`new PubSubOptions()`](#new-pubsuboptions)
  - [`new PubSubOptions (url, isAutoReconnect, connectTimeoutMs, sessionUuid)`](#new-pubsuboptions-isautoreconnect-connecttimeoutms-sessionUuid)
- [`PubSubHandle`](#pubsubhandle)
  - [`getSessionUuid()`](#setsessionuuid)
  - [`subscribe (channel, handler)`](#subscribe-channel-handler)
  - [`unsubscribe (channel)`](#unsubscribe-channel)
  - [`unsubscribeAll()`](#unsubscribeall)
  - [`listSubscriptions()`](#listsubscriptions)
  - [`publish (channel, message)`](#publish-channel-message)
  - [`publishWithAck (channel, message)`](#publishwithack-channel-message)
  - [`close()`](#close)
- [A complete example](#a-complete-example)
- [Running the tests](#running-the-tests)

## Code Examples

The code examples that follow illustrate the individual methods of the Android
Cogswell.ioPub/Sub SDK. The examples illustrate only how the methods might be
used. For more information, including complete method signatures and possible
errors, see the documentation at [the Cogswell.ioPub/Sub website](https://cogswell.io/docs/android/client-sdk/api/).

To support versions of Android as old as API level 15, this SDK uses the [Guava](https://github/google/guava) library for async calls.

[A complete example](#a-complete-example), illustrating how the methods can be used
together, is provided at the end of this document.

### [`PubSubSDK`](#pubsubsdk)

#### [`getInstance()`](#getinstance)
You can use the `getInstance` method to get a reference to the sdk.
```java
PubSubSDK sdk = PubSubSDK.getInstance();
```

#### [`connect (keys)`](#connect-keys)
You'll need to get your the from your Cogswell.io pub/sub account.
```java
List<String> keys = new ArrayList<String>();
keys.add("A-*-*");
keys.add("R-*-*");
keys.add("W-*-*");
```

```java
ListenableFuture<PubSubHandle> connectFuture = PubSubSDK.getInstance().connect(keys);

Futures.addCallback(connectFuture, new FutureCallback<PubSubHandle>() {
    public void onSuccess(PubSubHandle psh) {
        Log.e("TEST","Connected");
    }
{'fraction_non_alphanumeric': 0.16250281341435965, 'fraction_numerical': 0.0013504388926401081, 'mean_word_length': 5.702865761689291, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4281124', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1330, 'n_words': 349}