Package org.fusesource.mqtt.codec

Examples of org.fusesource.mqtt.codec.CONNECT


            return null;
        try {
            switch (frame.messageType()) {
                case PINGREQ.TYPE: return new PINGREQ().decode(frame).toString();
                case PINGRESP.TYPE: return new PINGRESP().decode(frame).toString();
                case CONNECT.TYPE: return new CONNECT().decode(frame).toString();
                case DISCONNECT.TYPE: return new DISCONNECT().decode(frame).toString();
                case SUBSCRIBE.TYPE: return new SUBSCRIBE().decode(frame).toString();
                case UNSUBSCRIBE.TYPE: return new UNSUBSCRIBE().decode(frame).toString();
                case PUBLISH.TYPE: return new PUBLISH().decode(frame).toString();
                case PUBACK.TYPE: return new PUBACK().decode(frame).toString();
View Full Code Here


        h.codecHandler(new Handler<MQTTFrame>() {
            @Override
            public void handle(MQTTFrame event) {
                try {
                    if (event.messageType() == org.fusesource.mqtt.codec.CONNECT.TYPE) {
                        CONNECT connect = new CONNECT().decode(event);
                        ConnectionParameters parameters = new ConnectionParameters();
                        if( connect.clientId()!=null ) {
                            parameters.protocolClientId = connect.clientId().toString();
                        }
                        if( connect.userName()!=null ) {
                            parameters.protocolUser = connect.userName().toString();

                            // If the user name has a '/' in it, then interpret it as
                            // containing the virtual host info.
                            if( parameters.protocolUser.contains("/") ) {

                                // Strip off the virtual host part of the username..
                                String[] parts = parameters.protocolUser.split("/", 2);

                                parameters.protocolVirtualHost = parts[0];
                                parameters.protocolUser = parts[1];

                                // Update the connect frame to strip out the virtual host from the username field...
                                connect.userName(new UTF8Buffer(parameters.protocolUser));

                                // re-write the received buffer /w  the updated connect frame
                                Buffer tail = received.getBuffer((int) h.getBytesDecoded(), received.length());
                                BufferSupport.setLength(received, 0);
                                append(received, connect.encode());
                                received.appendBuffer(tail);
                            }
                        }
                        handler.handle(parameters);
                    } else {
View Full Code Here

TOP

Related Classes of org.fusesource.mqtt.codec.CONNECT

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.