Skip to content

Commit

Permalink
fix for #35 (promises prematurely flushed without resolution)
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Apr 24, 2019
1 parent 2f4b137 commit 4fe0583
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
@@ -1,4 +1,4 @@
# Tindroid: Tinode Android client.
# Tindroid: Tinode Messaging Client for Android

Android instant messenger using [Tinode](https://github.com/tinode/chat/) backend. Beta-quality software.
Debug APKs are available in [releases](https://github.com/tinode/tindroid/releases).
Expand Down Expand Up @@ -59,10 +59,10 @@ Demo avatars and some other graphics are from https://www.pexels.com/ under [CC0

Background patterns from http://subtlepatterns.com/, commercial and non-commercial use allowed with attribution.

The `contacts.vcf` contains a list of contacts which can be used for testing. Push it to your emulator using

`adb push contacts.vcf /sdcard/contacts.vcf`

The [`contacts.vcf`](./contacts.vcf) contains a list of contacts which can be used for testing. Push it to your emulator using command
```
adb push contacts.vcf /sdcard/contacts.vcf`
```

## Translations

Expand Down
14 changes: 7 additions & 7 deletions tinodesdk/src/main/java/co/tinode/tinodesdk/Tinode.java
Expand Up @@ -445,19 +445,12 @@ public boolean reconnectNow() throws IOException {
}

private void handleDisconnect(boolean byServer, int code, String reason) {
mFutures.clear();

mConnAuth = false;

// TODO(gene): should this be cleared?
mServerBuild = null;
mServerVersion = null;

// Mark all topics as un-attached.
for (Topic topic : mTopics.values()) {
topic.topicLeft(false, 503, "disconnected");
}

// Reject all pending promises.
ServerResponseException ex = new ServerResponseException(503, "disconnected");
for (PromisedReply<ServerMessage> p : mFutures.values()) {
Expand All @@ -467,6 +460,13 @@ private void handleDisconnect(boolean byServer, int code, String reason) {
}
}

mFutures.clear();

// Mark all topics as un-attached.
for (Topic topic : mTopics.values()) {
topic.topicLeft(false, 503, "disconnected");
}

if (mListener != null) {
mListener.onDisconnect(byServer, code, reason);
}
Expand Down

0 comments on commit 4fe0583

Please sign in to comment.