Wrong presence channel behavior (Android/IOS)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Java
- Star
- 315
- Fork
- 140
- Merge trung bình
- 10 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pusher/pusher-websocket-java
-
java.lang.NoClassDefFoundError: com.pusher.client.Pusher$$ExternalSyntheticLambda0 on Android API 21-22 anywayCó thể đã có người làm @Keith-wright đã nhận 9 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
pusher/pusher-websocket-java#366 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
pusher/pusher-websocket-java#340 · 3 bình luận · 7 reaction ·
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 8/100
pusher/pusher-websocket-java#311 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 12/100
pusher/pusher-websocket-java#308 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
pusher/pusher-websocket-java#303 · 4 bình luận ·
Tất cả issue của pusher/pusher-websocket-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
build
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
MetricsHub/metricshub-community#1472 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
IdentityArrayObjectSet iterator remove may throw ArrayIndexOutOfBoundsExceptionCó thể đã có người làm @jiteshkhatri11 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
javapathfinder/jpf-core#660 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày