sdk-for-android icon indicating copy to clipboard operation
sdk-for-android copied to clipboard

🐛 Bug Report: Realtime create socket mutlitimes!

Open gezihua123 opened this issue 1 year ago • 0 comments

👟 Reproduction steps

https://github.com/appwrite/sdk-for-android/blob/85fac9dedd90eefe8407382cdd9f54b436862703/library/src/main/java/io/appwrite/services/Realtime.kt#L116-L123

when call this job in multiple threads ,it may call createSocket twice times or more?

👍 Expected behavior

when call this job in multiple threads ,it may call createSocket once. It will be ok by this code .

private var subCallDepth  = AtomicInteger(0)
delay(DEBOUNCE_MILLIS)

if (subCallDepth.compareAndSet(0,1)) {
    createSocket()
}

👎 Actual Behavior

it may call createSocket twice times or more?

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Linux

🧱 Your Environment

android

👀 Have you spent some time to check if this issue has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

gezihua123 avatar Sep 25 '24 08:09 gezihua123