diff --git a/src/main/java/com/pusher/client/channel/Channel.java b/src/main/java/com/pusher/client/channel/Channel.java index 542038e0..90289bed 100644 --- a/src/main/java/com/pusher/client/channel/Channel.java +++ b/src/main/java/com/pusher/client/channel/Channel.java @@ -63,7 +63,7 @@ public interface Channel { * {@link com.pusher.client.Pusher#subscribe(String, ChannelEventListener, String...)} * again to receive a fresh {@linkplain Channel} instance. */ - void bind_global(SubscriptionEventListener listener); + void bindGlobal(SubscriptionEventListener listener); /** *

@@ -129,7 +129,7 @@ public interface Channel { * {@link com.pusher.client.Pusher#subscribe(String, ChannelEventListener, String...)} * again to receive a fresh {@linkplain Channel} instance. */ - void unbind_global(SubscriptionEventListener listener); + void unbindGlobal(SubscriptionEventListener listener); /** * diff --git a/src/main/java/com/pusher/client/channel/impl/ChannelImpl.java b/src/main/java/com/pusher/client/channel/impl/ChannelImpl.java index cb1e19b5..399816ed 100644 --- a/src/main/java/com/pusher/client/channel/impl/ChannelImpl.java +++ b/src/main/java/com/pusher/client/channel/impl/ChannelImpl.java @@ -17,7 +17,7 @@ public class ChannelImpl implements InternalChannel { private static final String INTERNAL_EVENT_PREFIX = "pusher_internal:"; protected static final String SUBSCRIPTION_SUCCESS_EVENT = "pusher_internal:subscription_succeeded"; protected final String name; - private Set globalListners = new HashSet(); + private Set globalListeners = new HashSet(); private final Map> eventNameToListenerMap = new HashMap>(); protected volatile ChannelState state = ChannelState.INITIAL; private ChannelEventListener eventListener; @@ -68,14 +68,11 @@ public void bind(final String eventName, final SubscriptionEventListener listene } @Override - public void bind_global(SubscriptionEventListener listener) { + public void bindGlobal(SubscriptionEventListener listener) { validateArguments("", listener); synchronized(lock) { - if (globalListners == null) { - globalListners = new HashSet(); - } - globalListners.add(listener); + globalListeners.add(listener); } } @@ -96,12 +93,12 @@ public void unbind(final String eventName, final SubscriptionEventListener liste } @Override - public void unbind_global(SubscriptionEventListener listener) { + public void unbindGlobal(SubscriptionEventListener listener) { validateArguments("", listener); synchronized(lock) { - if (globalListners != null) { - globalListners.remove(listener); + if (globalListeners != null) { + globalListeners.remove(listener); } } } @@ -244,8 +241,8 @@ protected Set getInterestedListeners(String event) { if (sharedListeners != null ) { listners.addAll(sharedListeners); } - if (!globalListners.isEmpty()) { - listners.addAll(globalListners); + if (!globalListeners.isEmpty()) { + listners.addAll(globalListeners); } if (listners.isEmpty()){ diff --git a/src/test/java/com/pusher/client/channel/impl/ChannelImplTest.java b/src/test/java/com/pusher/client/channel/impl/ChannelImplTest.java index bf922dc2..5699a4a0 100644 --- a/src/test/java/com/pusher/client/channel/impl/ChannelImplTest.java +++ b/src/test/java/com/pusher/client/channel/impl/ChannelImplTest.java @@ -121,7 +121,7 @@ public void testDataIsExtractedFromMessageAndPassedToSingleListener() { } @Test public void testDataIsExtractedFromMessageAndPassedToSingleListenerGlobalEvent() { - channel.bind_global(mockListener); + channel.bindGlobal(mockListener); channel.onMessage(EVENT_NAME, "{\"event\":\"event1\",\"data\":\"{\\\"fish\\\":\\\"chips\\\"}\"}"); verify(mockListener, times(1)).onEvent(argCaptor.capture()); @@ -166,8 +166,8 @@ public void testEventIsNotPassedOnIfListenerHasUnboundFromEvent() { @Test public void testEventIsNotPassedOnIfListenerHasUnboundFromGlobalEvent() { - channel.bind_global(mockListener); - channel.unbind_global(mockListener); + channel.bindGlobal(mockListener); + channel.unbindGlobal(mockListener); channel.onMessage(EVENT_NAME, "{\"event\":\"event1\",\"data\":\"{\\\"fish\\\":\\\"chips\\\"}\"}"); verify(mockListener, never()).onEvent(any(PusherEvent.class)); diff --git a/src/test/java/com/pusher/client/channel/impl/PrivateEncryptedChannelImplTest.java b/src/test/java/com/pusher/client/channel/impl/PrivateEncryptedChannelImplTest.java index da81aacf..7bcabf8d 100644 --- a/src/test/java/com/pusher/client/channel/impl/PrivateEncryptedChannelImplTest.java +++ b/src/test/java/com/pusher/client/channel/impl/PrivateEncryptedChannelImplTest.java @@ -208,7 +208,7 @@ public void testDataIsExtractedFromMessageAndPassedToSingleListenerGlobalEvent() PrivateEncryptedChannelEventListener mockListener = mock(PrivateEncryptedChannelEventListener.class); - channel.bind_global(mockListener); + channel.bindGlobal(mockListener); channel.onMessage("my-event", "{\"event\":\"event1\",\"data\":\"{" + "\\\"nonce\\\": \\\"4sVYwy4j/8dCcjyxtPCWyk19GaaViaW9\\\"," +