diff --git a/History.md b/History.md index 02f66f43..18e4f07b 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,56 @@ +2.1.0 / 2022-07-10 +================== + +### Bug Fixes + +* ensure randomizationFactor is always between 0 and 1 ([0cbf01e](https://github.com/socketio/socket.io-client-java/commit/0cbf01eb2501b3098eacd22594966a719b20c31e)) +* prevent socket from reconnecting after middleware failure ([95ecf22](https://github.com/socketio/socket.io-client-java/commit/95ecf222d25de390d8c0f2ffade37b608cf448eb)) +* increase the readTimeout value of the default OkHttpClient ([fb531fa](https://github.com/socketio/engine.io-client-java/commit/fb531fab30968a4b65a402c81f37e92dd5671f33)) (from `engine.io-client`) + +### Features + +* emit with timeout ([fca3b95](https://github.com/socketio/socket.io-client-java/commit/fca3b9507d5bc79d3c41ab6e119efccd23669ca6)) + +This feature allows to send a packet and expect an acknowledgement from the server within the given delay. + +Syntax: + +```java +socket.emit("hello", "world", new AckWithTimeout(5000) { + @Override + public void onTimeout() { + // ... + } + + @Override + public void onSuccess(Object... args) { + // ... + } +}); +``` + +* implement catch-all listeners ([c7d50b8](https://github.com/socketio/socket.io-client-java/commit/c7d50b8ae9787e9ebdff50aa5d36f88433fc50b9)) + +Syntax: + +```java +socket.onAnyIncoming(new Emitter.Listener() { + @Override + public void call(Object... args) { + // ... + } +}); + +socket.onAnyOutgoing(new Emitter.Listener() { + @Override + public void call(Object... args) { + // ... + } +}); +``` + + 2.0.1 / 2021-04-27 ================== diff --git a/pom.xml b/pom.xml index d4651806..e6ff6051 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.socket socket.io-client - 2.0.2-SNAPSHOT + 2.1.0 jar socket.io-client Socket.IO Client Library for Java @@ -30,7 +30,7 @@ https://github.com/socketio/socket.io-client-java scm:git:https://github.com/socketio/socket.io-client-java.git scm:git:https://github.com/socketio/socket.io-client-java.git - HEAD + socket.io-client-2.1.0 diff --git a/src/site/markdown/changelog.md b/src/site/markdown/changelog.md index a7a5866d..d197c228 100644 --- a/src/site/markdown/changelog.md +++ b/src/site/markdown/changelog.md @@ -1,4 +1,57 @@ +## [2.1.0](https://github.com/socketio/socket.io-client-java/compare/socket.io-client-2.0.1...socket.io-client-2.1.0) (2022-07-10) + + +### Bug Fixes + +* ensure randomizationFactor is always between 0 and 1 ([0cbf01e](https://github.com/socketio/socket.io-client-java/commit/0cbf01eb2501b3098eacd22594966a719b20c31e)) +* prevent socket from reconnecting after middleware failure ([95ecf22](https://github.com/socketio/socket.io-client-java/commit/95ecf222d25de390d8c0f2ffade37b608cf448eb)) +* increase the readTimeout value of the default OkHttpClient ([fb531fa](https://github.com/socketio/engine.io-client-java/commit/fb531fab30968a4b65a402c81f37e92dd5671f33)) (from `engine.io-client`) + +### Features + +* emit with timeout ([fca3b95](https://github.com/socketio/socket.io-client-java/commit/fca3b9507d5bc79d3c41ab6e119efccd23669ca6)) + +This feature allows to send a packet and expect an acknowledgement from the server within the given delay. + +Syntax: + +```java +socket.emit("hello", "world", new AckWithTimeout(5000) { + @Override + public void onTimeout() { + // ... + } + + @Override + public void onSuccess(Object... args) { + // ... + } +}); +``` + +* implement catch-all listeners ([c7d50b8](https://github.com/socketio/socket.io-client-java/commit/c7d50b8ae9787e9ebdff50aa5d36f88433fc50b9)) + +Syntax: + +```java +socket.onAnyIncoming(new Emitter.Listener() { + @Override + public void call(Object... args) { + // ... + } +}); + +socket.onAnyOutgoing(new Emitter.Listener() { + @Override + public void call(Object... args) { + // ... + } +}); +``` + + + ## [2.0.1](https://github.com/socketio/socket.io-client-java/compare/socket.io-client-2.0.0...socket.io-client-2.0.1) (2021-04-27) diff --git a/src/site/markdown/emitting_events.md b/src/site/markdown/emitting_events.md index 5f298ffb..4526a491 100644 --- a/src/site/markdown/emitting_events.md +++ b/src/site/markdown/emitting_events.md @@ -146,3 +146,21 @@ socket.on("hello", args -> { } }); ``` + +## With timeout + +Starting with version `2.1.0`, you can now assign a timeout to each emit: + +```java +socket.emit("hello", "world", new AckWithTimeout(5000) { + @Override + public void onTimeout() { + // ... + } + + @Override + public void onSuccess(Object... args) { + // ... + } +}); +``` diff --git a/src/site/markdown/installation.md b/src/site/markdown/installation.md index c4eef2a8..a14593a8 100644 --- a/src/site/markdown/installation.md +++ b/src/site/markdown/installation.md @@ -17,7 +17,7 @@ Add the following dependency to your `pom.xml`. io.socket socket.io-client - 2.0.1 + 2.1.0 ``` @@ -26,7 +26,7 @@ Add the following dependency to your `pom.xml`. Add it as a gradle dependency for Android Studio, in `build.gradle`: ```groovy -implementation ('io.socket:socket.io-client:2.0.1') { +implementation ('io.socket:socket.io-client:2.1.0') { // excluding org.json which is provided by Android exclude group: 'org.json', module: 'json' } @@ -36,6 +36,7 @@ implementation ('io.socket:socket.io-client:2.0.1') { | `socket.io-client` | `engine.io-client` | `okhttp` | |-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| +| `2.1.0` ([diff](https://github.com/socketio/socket.io-client-java/compare/socket.io-client-2.0.1...socket.io-client-2.1.0)) | `2.1.0` ([diff](https://github.com/socketio/engine.io-client-java/compare/engine.io-client-2.0.0...engine.io-client-2.1.0)) | `3.12.12` | | `2.0.1` ([diff](https://github.com/socketio/socket.io-client-java/compare/socket.io-client-2.0.0...socket.io-client-2.0.1)) | `2.0.0` | `3.12.12` | | `2.0.0` ([diff](https://github.com/socketio/socket.io-client-java/compare/socket.io-client-1.0.1...socket.io-client-2.0.0)) | `2.0.0` ([diff](https://github.com/socketio/engine.io-client-java/compare/engine.io-client-1.0.1...engine.io-client-2.0.0)) | `3.12.12` | | `1.0.1` ([diff](https://github.com/socketio/socket.io-client-java/compare/socket.io-client-1.0.0...socket.io-client-1.0.1)) | `1.0.1` ([diff](https://github.com/socketio/engine.io-client-java/compare/engine.io-client-1.0.0...engine.io-client-1.0.1)) | `3.12.12` ([changelog](https://square.github.io/okhttp/changelogs/changelog_3x/#version-31212)) | diff --git a/src/site/markdown/listening_to_events.md b/src/site/markdown/listening_to_events.md index 6a740658..843fb182 100644 --- a/src/site/markdown/listening_to_events.md +++ b/src/site/markdown/listening_to_events.md @@ -69,3 +69,27 @@ Removes all listeners (for any event). ```java socket.off(); ``` + +## Catch-all listeners + +### For incoming packets + +```java +socket.onAnyIncoming(new Emitter.Listener() { + @Override + public void call(Object... args) { + // ... + } +}); +``` + +### For outgoing packets + +```java +socket.onAnyOutgoing(new Emitter.Listener() { + @Override + public void call(Object... args) { + // ... + } +}); +```