Package org.jboss.aerogear.simplepush.protocol

Examples of org.jboss.aerogear.simplepush.protocol.MessageType


            public void onOpen() {
            }

            @Override
            public void onMessage(String message) {
                final MessageType messageType = JsonUtil.parseFrame(message);
                switch (messageType.getMessageType()) {
                case REGISTER:
                    final RegisterResponseImpl registerResponse = JsonUtil.fromJson(message, RegisterResponseImpl.class);
                    if (registrationListener != null) {
                        registrationListener.onRegistered(registerResponse.getChannelId(), registerResponse.getPushEndpoint());
                    }
View Full Code Here


    @Override
    public void handle(final SockJSSocket sock) {
        sock.dataHandler(new Handler<Buffer>() {
            @Override
            public void handle(final Buffer buffer) {
                final MessageType messageType = JsonUtil.parseFrame(buffer.toString());
                switch (messageType.getMessageType()) {
                    case HELLO:
                        HelloMessage handshakeMessage = fromJson(buffer.toString(), HelloMessageImpl.class);
                        if (!writeHandlerMap.containsKey(handshakeMessage.getUAID())) {
                            handshakeMessage = new HelloMessageImpl(UUIDUtil.newUAID());
                        }
View Full Code Here

        @Override
        public MessageType deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException {
            final ObjectCodec oc = jp.getCodec();
            final JsonNode node = oc.readTree(jp);
            final JsonNode messageTypeNode = node.get(MessageType.MESSSAGE_TYPE_FIELD);
            return new MessageType() {
                @Override
                public Type getMessageType() {
                    if (messageTypeNode == null) {
                        return MessageType.Type.PING;
                    }
View Full Code Here

    }

    @Override
    @SuppressWarnings("incomplete-switch")
    public void onMessage(final String message) throws Exception {
        final MessageType messageType = JsonUtil.parseFrame(message);
        logger.info("messageType: " + messageType.getMessageType());
        switch (messageType.getMessageType()) {
        case HELLO:
            if (!checkHandshakeCompleted(uaid)) {
                final HelloResponse response = simplePushServer.handleHandshake(fromJson(message, HelloMessageImpl.class));
                session.send(toJson(response));
                uaid = response.getUAID();
View Full Code Here

    @Test
    public void parseFrame() {
        final String uaid = UUIDUtil.newUAID();
        final String json = "{\"messageType\": \"hello\", \"uaid\": \"" + uaid + "\", \"channelIDs\": [\"123abc\", \"efg456\"]}";
        final MessageType messageType = JsonUtil.parseFrame(json);
        assertThat(messageType.getMessageType(), is(equalTo(MessageType.Type.HELLO)));
    }
View Full Code Here

    private static final Logger LOGGER = Logger.getLogger(EchoEndpoint.class.getName());

    @OnMessage
    public void receiveTextMessage(String message, Session session) throws IOException {
        String request = message;
        final MessageType messageType = JsonUtil.parseFrame(request);
        switch (messageType.getMessageType()) {
            case HELLO:
                session.getBasicRemote().sendText(JsonUtil.toJson(new HelloResponseImpl(UUIDUtil.newUAID())));
                break;
            case REGISTER:
                final RegisterMessageImpl registerMessage = JsonUtil.fromJson(request, RegisterMessageImpl.class);
View Full Code Here

            ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
            return;
        }
        if (frame instanceof TextWebSocketFrame) {
            String request = ((TextWebSocketFrame) frame).text();
            final MessageType messageType = JsonUtil.parseFrame(request);
            switch (messageType.getMessageType()) {
                case HELLO:
                    ctx.channel().write(new TextWebSocketFrame(JsonUtil.toJson(new HelloResponseImpl(UUIDUtil.newUAID()))));
                    break;
                case REGISTER:
                    final RegisterMessageImpl registerMessage = JsonUtil.fromJson(request, RegisterMessageImpl.class);
View Full Code Here

                                    @Override
                                    protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) {
                                        LOGGER.info("Received Text Message");
                                        String request = message.getData();
                                        final MessageType messageType = JsonUtil.parseFrame(request);
                                        switch (messageType.getMessageType()) {
                                            case HELLO:
                                                WebSockets.sendText(JsonUtil.toJson(new HelloResponseImpl(UUIDUtil.newUAID())), channel, null);
                                                break;
                                            case REGISTER:
                                                final RegisterMessageImpl registerMessage = JsonUtil.fromJson(request, RegisterMessageImpl.class);
View Full Code Here

                            if (webSocketFrame.isBinary()) {
                                Buffer buff = new Buffer(((WebSocketFrameInternal) webSocketFrame).getBinaryData());
                                ws.writeBinaryFrame(buff);
                            } else if (webSocketFrame.isText()) {
                                String request = webSocketFrame.textData();
                                final MessageType messageType = JsonUtil.parseFrame(request);
                                switch (messageType.getMessageType()) {
                                    case HELLO:
                                        ws.writeTextFrame(JsonUtil.toJson(new HelloResponseImpl(UUIDUtil.newUAID())));
                                        break;
                                    case REGISTER:
                                        final RegisterMessageImpl registerMessage = JsonUtil.fromJson(request, RegisterMessageImpl.class);
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.simplepush.protocol.MessageType

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.