Skip to content

Commit 91a870a

Browse files
committed
release v1.1.2
1 parent 576241c commit 91a870a

File tree

6 files changed

+22
-34
lines changed

6 files changed

+22
-34
lines changed

README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ KMP (pure Kotlin) implementation of SocketIO client.
99
| Platform | 🛠Builds🛠 + 🔬Tests🔬 |
1010
| :----------------: | :------------------: |
1111
| `JVM` 17 | 🚀 |
12-
| `Browser` (Chrome) | 🚀 |
12+
| `JS` (Chrome) | 🚀 |
13+
| `WasmJS` (Chrome) | 🚀 |
1314
| `Android` | 🚀 |
1415
| `iOS` | 🚀 |
1516
| `macOS` | 🚀 |
@@ -63,26 +64,13 @@ Most of the APIs are the same as socket.io-client-java, here are some difference
6364
- Create socket is asynchronous, to make it's easier to guarantee thread safety.
6465
- Binary messages can't be nested, because `emit` only accepts String/Boolean/Number/JsonElement/ByteString, other types will be converted to String using `toString()`, so there is no way to put ByteString in JsonElement.
6566

66-
### Set logging callback
67-
68-
```kotlin
69-
Logger.setLogger(object : LoggerInterface {
70-
override fun debug(tag: String, log: String) {
71-
TODO("Not yet implemented")
72-
}
73-
74-
override fun info(tag: String, log: String) {
75-
TODO("Not yet implemented")
76-
}
77-
78-
override fun error(tag: String, log: String) {
79-
TODO("Not yet implemented")
80-
}
81-
})
82-
```
67+
### Logging with [kmp-xlog](https://github.com/HackWebRTC/kmp-xlog)
8368

8469
## Example
8570

71+
Before running examples, run `node kmp-socketio/src/jvmTest/resources/socket-server.js` to start the socket-io echo server,
72+
and update the local IP address in `example/shared/src/commonMain/kotlin/com/piasy/kmp/socketio/example/Greeting.kt`.
73+
8674
### Android
8775

8876
Open the project (the repo root dir) in Android studio, and run the example.androidApp target.
@@ -105,6 +93,8 @@ Use Chrome CORS Unblock extension to workaround with CORS error.
10593

10694
### WASM JS
10795

96+
Use Chrome CORS Unblock extension to workaround with CORS error.
97+
10898
```bash
10999
./gradlew :example:shared:wasmJsBrowserRun
110100
```

buildSrc/src/main/kotlin/Constants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Consts {
22
const val releaseGroup = "com.piasy"
33
const val releaseName = "kmp-socketio"
4-
const val releaseVersion = "1.1.1"
4+
const val releaseVersion = "1.1.2"
55

66
val androidNS = "$releaseGroup.${releaseName.replace('-', '_')}"
77
}

example/shared/src/commonMain/kotlin/com/piasy/kmp/socketio/example/Greeting.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ import kotlinx.io.bytestring.unsafe.UnsafeByteStringOperations
1010
class Greeting {
1111
@OptIn(UnsafeByteStringApi::class)
1212
fun greet() {
13-
IO.socket(
14-
"https://echo.websocket.org/",
15-
IO.Options().apply {
16-
transports = listOf("websocket")
17-
}
18-
) { socket ->
13+
IO.socket("http://172.16.11.25:3000", IO.Options()) { socket ->
1914
socket.on(Socket.EVENT_CONNECT) { args ->
20-
println("on connect ${args.joinToString()}")
15+
println("Greeting on connect ${args.joinToString()}")
2116

2217
val bin = UnsafeByteStringOperations.wrapUnsafe(byteArrayOf(0x1, 0x3, 0x1, 0x4))
2318
socket.emit("echo", 1, "2", bin, GMTDate())
2419
}.on("echoBack") { args ->
25-
println("on echoBack ${args.joinToString()}")
20+
println("Greeting on echoBack ${args.joinToString()}")
2621
}
2722

2823
socket.open()

gradle/libs.versions.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ iosDeploymentTarget = "14.0"
44
compileSdk = "35"
55
minSdk = "21"
66
targetSdk = "35"
7-
agp = "8.8.0"
7+
agp = "8.7.3"
88
kotlin = "2.1.0"
99
mockk = "1.13.16"
1010
ktor = "3.0.3"
1111
coroutine = "1.10.1"
12-
compose = "1.7.6"
13-
kotlinxBrowser = "0.3"
14-
kmpXlog = "1.3.1"
12+
compose = "1.7.7"
1513

1614
[libraries]
1715
junit = "junit:junit:4.13.2"
@@ -22,7 +20,7 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t
2220
json = "org.json:json:20250107"
2321
socketioParser = "org.hildan.socketio:socketio-kotlin:2.0.0"
2422
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutine" }
25-
kotlinx-browser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinxBrowser" }
23+
kotlinx-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.3"
2624
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
2725
ktor-client-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "ktor" }
2826
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
@@ -34,7 +32,7 @@ ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
3432
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
3533
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" }
3634
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
37-
kmpXlog = { module = "com.piasy:kmp-xlog", version.ref = "kmpXlog" }
35+
kmpXlog = "com.piasy:kmp-xlog:1.3.1"
3836

3937
androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
4038
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }

kmp-socketio/src/commonMain/kotlin/com/piasy/kmp/socketio/engineio/transports/PollingXHR.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ open class PollingXHR(
142142
} else {
143143
EngineIO.decodeHttpBatch(data, SocketIO::decode)
144144
}
145-
} catch (e: InvalidSocketIOPacketException) {
145+
} catch (e: Exception) { // InvalidSocketIOPacketException | InvalidEngineIOPacketException
146146
val log = "onPollComplete decode error: ${e.message}"
147147
logE(log)
148148
onError(log)

kotlin-js-store/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
"@jridgewell/resolve-uri" "^3.1.0"
5858
"@jridgewell/sourcemap-codec" "^1.4.14"
5959

60+
"@js-joda/core@3.2.0":
61+
version "3.2.0"
62+
resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273"
63+
integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg==
64+
6065
"@leichtgewicht/ip-codec@^2.0.1":
6166
version "2.0.4"
6267
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"

0 commit comments

Comments
 (0)