Package com.pusher.client.channel

Examples of com.pusher.client.channel.ChannelEventListener


        assertEquals("{\"name\":\"Phil Leggetter\",\"twitter_id\":\"@leggetter\"}", user.getInfo());
    }

    @Test(expected = IllegalArgumentException.class)
    public void testCannotBindIfListenerIsNotAPresenceChannelEventListener() {
        ChannelEventListener listener = mock(PrivateChannelEventListener.class);
        channel.bind("private-myEvent", listener);
    }
View Full Code Here


        ((PrivateChannelImpl) channel).trigger("client-myEvent", "{\"fish\":\"chips\"}");
    }

    @Test(expected = IllegalArgumentException.class)
    public void testCannotBindIfListenerIsNotAPrivateChannelEventListener() {
        ChannelEventListener listener = mock(ChannelEventListener.class);
        channel.bind("private-myEvent", listener);
    }
View Full Code Here

                "{\"fish\":\"chips\"}");
    }

    @Test
    public void testDataIsExtractedFromMessageAndPassedToMultipleListeners() {
        ChannelEventListener mockListener2 = getEventListener();

        channel.bind(EVENT_NAME, mockListener);
        channel.bind(EVENT_NAME, mockListener2);
        channel.onMessage(EVENT_NAME,
                "{\"event\":\"event1\",\"data\":\"{\\\"fish\\\":\\\"chips\\\"}\"}");
View Full Code Here

    /**
     * This method is overridden to allow the private and presence channel tests
     * to use the appropriate listener subclass.
     */
    protected ChannelEventListener getEventListener() {
        ChannelEventListener listener = mock(ChannelEventListener.class);
        return listener;
    }
View Full Code Here

            factory.getEventQueue().execute(new Runnable() {

                public void run() {
                    // Note: this cast is safe because an AuthorizationFailureException will never be thrown
                    // when subscribing to a non-private channel
                    ChannelEventListener eventListener = channel.getEventListener();
                    PrivateChannelEventListener privateChannelListener = (PrivateChannelEventListener) eventListener;
                    privateChannelListener.onAuthenticationFailure(e.getMessage(), e);
                }
            });
        }
View Full Code Here

            String userData = (hash.get(id) != null) ? new Gson().toJson(hash.get(id)) : null;
            User user = new User(id, userData);
            idToUserMap.put(id, user);
        }

        ChannelEventListener listener = this.getEventListener();
        if (listener != null) {
            PresenceChannelEventListener presenceListener = (PresenceChannelEventListener)listener;
            presenceListener.onUsersInformationReceived(getName(), getUsers());
        }
    }
View Full Code Here

        String userData = (dataMap.get("user_info") != null) ? new Gson().toJson(dataMap.get("user_info")) : null;

        final User user = new User(id, userData);
        idToUserMap.put(id, user);

        ChannelEventListener listener = this.getEventListener();
        if (listener != null) {
            PresenceChannelEventListener presenceListener = (PresenceChannelEventListener)listener;
            presenceListener.userSubscribed(getName(), user);
        }
    }
View Full Code Here

        Map dataMap = extractDataMapFrom(message);
        String id = String.valueOf(dataMap.get("user_id"));

        final User user = idToUserMap.remove(id);

        ChannelEventListener listener = this.getEventListener();
        if( listener != null ) {
            PresenceChannelEventListener presenceListener = (PresenceChannelEventListener)listener;
            presenceListener.userUnsubscribed(getName(), user);
        }
    }
View Full Code Here

TOP

Related Classes of com.pusher.client.channel.ChannelEventListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.