|
1 | 1 | package com.pusher.client.channel.impl;
|
2 | 2 |
|
3 |
| -import java.util.Collections; |
4 |
| -import java.util.LinkedHashMap; |
5 |
| -import java.util.LinkedHashSet; |
6 |
| -import java.util.List; |
7 |
| -import java.util.Map; |
8 |
| -import java.util.Set; |
9 |
| - |
10 | 3 | import com.google.gson.Gson;
|
11 | 4 | import com.google.gson.annotations.SerializedName;
|
12 |
| - |
13 | 5 | import com.pusher.client.AuthorizationFailureException;
|
14 | 6 | import com.pusher.client.Authorizer;
|
15 | 7 | import com.pusher.client.channel.ChannelEventListener;
|
|
20 | 12 | import com.pusher.client.connection.impl.InternalConnection;
|
21 | 13 | import com.pusher.client.util.Factory;
|
22 | 14 |
|
| 15 | +import java.util.Collections; |
| 16 | +import java.util.LinkedHashMap; |
| 17 | +import java.util.LinkedHashSet; |
| 18 | +import java.util.List; |
| 19 | +import java.util.Map; |
| 20 | +import java.util.Set; |
| 21 | + |
23 | 22 | public class PresenceChannelImpl extends PrivateChannelImpl implements PresenceChannel {
|
24 | 23 |
|
25 | 24 | private static final String MEMBER_ADDED_EVENT = "pusher_internal:member_added";
|
@@ -126,13 +125,14 @@ private void handleSubscriptionSuccessfulMessage(final String message) {
|
126 | 125 | final List<String> ids = presenceData.ids;
|
127 | 126 | final Map<String, Object> hash = presenceData.hash;
|
128 | 127 |
|
129 |
| - // build the collection of Users |
130 |
| - for (final String id : ids) { |
131 |
| - final String userData = hash.get(id) != null ? GSON.toJson(hash.get(id)) : null; |
132 |
| - final User user = new User(id, userData); |
133 |
| - idToUserMap.put(id, user); |
| 128 | + if (ids != null && !ids.isEmpty()) { |
| 129 | + // build the collection of Users |
| 130 | + for (final String id : ids) { |
| 131 | + final String userData = hash.get(id) != null ? GSON.toJson(hash.get(id)) : null; |
| 132 | + final User user = new User(id, userData); |
| 133 | + idToUserMap.put(id, user); |
| 134 | + } |
134 | 135 | }
|
135 |
| - |
136 | 136 | final ChannelEventListener listener = getEventListener();
|
137 | 137 | if (listener != null) {
|
138 | 138 | final PresenceChannelEventListener presenceListener = (PresenceChannelEventListener)listener;
|
|
0 commit comments