appwrite / appwrite/sdk-for-android

🐛 Bug Report: Realtime create socket mutlitimes!

Open
#62 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
154
Forks
30
Avg merge
5h 41m
Merged PRs (30d)
3

Description

### 👟 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 .

```kotlin
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?

- [X] I have read the [Code of Conduct](https://github.com/appwrite/.github/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.