dotnet / dotnet/aspnetcore

No Java Documentation on RxJava Schedulers and Threading

Open
#30,272 2 comments 0 reactions 0 assignees View on GitHub
area-signalr enhancement
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Describe the bug
There is no documentation or references on what thread the SignalR Core code runs on and if the client needs to manage threading. We have implement as shown below but need clarification on:

1. If we need to specify with Rx scheduler to use for subscriptions and observations
2. What thread will the onClosed callbacks be called on. From what we see, it is run on the OkHttp thread.

### To Reproduce
We have implemented the library but subscribing `start(), invoke() and stop()` on the `Schedulers.io()` while observing on `AndroidSchedulers.mainThread()` where needed. Not sure if this is correct or even needed but it was done to ensure network activity is performed on a background thread.

The above also lets us ensure that our logic runs on the Main thread but the `onClosed` callback still runs on the `OkHttp thread.

```
onClosed { e ->
if (e == null) {
LogUtils.d(TAG, "Connection closed")
} else {
LogUtils.logMessageAndReportException(
TAG,
"createHubConnection()",
"Connection closed",
e
)
}
LogUtils.d(TAG, "Current thread: ${Thread.currentThread()}")
}
```

prints out `Current thread: Thread[OkHttp https://platform-sr.service.signalr.net/...,5,main]`

### Further technical details
- Java Client 5.0.3
- Android Studio 4.1.2

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.