Wrong presence channel behavior (Android/IOS)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- mobile-dev
Direzione di ricerca
The problem is in PresenceChannelImpl, in handleSubscriptionSuccessfulMessage, where idToUserMap is filled with put() calls but never cleared before the new user list is applied. Start by reading how idToUserMap is maintained across unsubscribe and resubscribe in PresenceChannelImpl. Done means that after a reconnect, getUsers() reflects only the users in the subscription_succeeded payload, and that a test covers a member leaving while the client was disconnected.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What is the issue?
Hello there! I found some incorrect behavior of presence channels after restore connection to channel.
Problem step-by-step:
- Connect to presence channel two or more users
- Go to in background - pusher disconnected
- Other users quit from channel
- Go to in foreground - pusher connected - we resubscribe to channel
- On onUsersInformationReceived we got old data of users in channel
Notate: Swift SDK has workaround with subscribing on "pusher:subscription_succeeded" and process this event separate from flow logic. In Java SDK we don't have such trick...
In PresenceChannelImpl when channel successfully subscribed we got event SUBSCRIPTION_SUCCESS_EVENT = "pusher_internal:subscription_succeeded" with processing in internal channel body and after that call onUsersInformationReceived for self interface.
Problem in idToUserMap map witch need to clear in this case, because if i'm not wrong with SUBSCRIPTION_SUCCESS_EVENT we getting actual data about users in presence channel but in current realisation we lost users who quit from channel while i was unsubscibed.
Debug of this point shown that problem exist - channel got json with 1 user but idToUserMap not cleared and return wrong users data
...
Is it a crash report? Submit stack traces or anything that you think would help
#class PresenceChannelImpl
@SuppressWarnings({ "rawtypes", "unchecked" })
private void handleSubscriptionSuccessfulMessage(final String message) {
final ChannelEventListener listener = getEventListener();
// extract data from the JSON message
final PresenceData presenceData = extractPresenceDataFrom(message);
if (presenceData == null) {
if (listener != null) {
listener.onError(
"Subscription failed: Presence data not found",
null
);
}
return;
}
final List<String> ids = presenceData.ids;
final Map<String, Object> hash = presenceData.hash;
if (ids != null && !ids.isEmpty()) {
// build the collection of Users
for (final String id : ids) {
final String userData = hash.get(id) != null ? GSON.toJson(hash.get(id)) : null;
final User user = new User(id, userData);
idToUserMap.put(id, user); <--- Problem - is not empty. Suggestion: need clear before process users data
}
}
if (listener != null) {
final PresenceChannelEventListener presenceListener = (PresenceChannelEventListener)listener;
presenceListener.onUsersInformationReceived(getName(), getUsers());
}
}
...
Any improvements you suggest
In this case clear idToUserMap before process users data. I may be wrong, then tell me the correct scenario for working with this type of channels
...
CC @pusher/mobile
- Lingua principale
- Java
- Stelle
- 315
- Fork
- 140
- Merge medio
- 11g 5h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pusher/pusher-websocket-java
-
FileNotFoundException thrown when server responds with 400 or aboveForse già presa @RaphaelFakhri l’ha presa 8 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
pusher/pusher-websocket-java#261 ·
-
java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anywayForse già presa @Keith-wright l’ha presa 9 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
pusher/pusher-websocket-java#366 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
pusher/pusher-websocket-java#340 · 3 commenti · 7 reazioni ·
-
Difficoltà 4/5 1-2 giorni Idoneità per principianti 8/100
pusher/pusher-websocket-java#311 · 4 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 12/100
pusher/pusher-websocket-java#308 · 2 commenti ·
Tutte le issue di pusher/pusher-websocket-java
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug/错误
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
FCL-Team/FoldCraftLauncher#1982 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] micronaut-serde-oracle-jdbc-json brings a second OJDBC driver onto the runtime classpathForse già presa @ZARAYACH l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
micronaut-projects/micronaut-serialization#1494 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 2 giorni