Package org.apache.mina.coap.codec

Examples of org.apache.mina.coap.codec.CoapEncoder


            channel.connect(target);

            System.err.println(channel);

            CoapEncoder encoder = new CoapEncoder();
            CoapDecoder decoder = new CoapDecoder();
            ByteBuffer buff = ByteBuffer.allocateDirect(2048);

            Random r = new Random();
            byte[] url = "nlp".getBytes();
            CoapMessage msg = new CoapMessage(1, MessageType.CONFIRMABLE, CoapCode.GET.getCode(), 1234, null,
                    new CoapOption[] { new CoapOption(CoapOptionType.URI_PATH, url) }, null);

            for (int j = 0; j < 8; j++) {
                long start = System.currentTimeMillis();
                final int count = 100000;
                for (int i = 0; i < count; i++) {
                    buff.position(0);
                    buff.limit(buff.capacity());
                    int id = r.nextInt(1024);
                    msg.setId(id);
                    int bytes = channel.send(encoder.encode(msg, null), target);

                    if (bytes < 1) {
                        System.err.println("write fail :/ " + bytes);
                    } else {
                        buff.position(0);
View Full Code Here


        final RequestFilter<CoapMessage, CoapMessage> rq = new RequestFilter<>();

        NioUdpClient client = new NioUdpClient();
        client.setFilters( //
                new ProtocolCodecFilter<CoapMessage, ByteBuffer, Void, Void>( //
                        new CoapEncoder(), new CoapDecoder() //
                ), rq);

        client.setIoHandler(new Handler());

        reg.register(new AbstractResourceHandler() {
View Full Code Here

        BioUdpServer server = new BioUdpServer();
        final RequestFilter<CoapMessage, CoapMessage> rq = new RequestFilter<>();

        server.setFilters(new ProtocolCodecFilter<CoapMessage, ByteBuffer, Void, Void>(
                new CoapEncoder(), new CoapDecoder()), rq);
        // idle in 10 minute
        server.getSessionConfig().setIdleTimeInMillis(IdleStatus.READ_IDLE, 60 * 10_000);
        server.setIoHandler(new AbstractIoHandler() {

            long start = System.currentTimeMillis();
View Full Code Here

        final RequestFilter<CoapMessage, CoapMessage> rq = new RequestFilter<>();

        NioUdpClient client = new NioUdpClient();
        client.setFilters( //
                new ProtocolCodecFilter<CoapMessage, ByteBuffer, Void, Void>( //
                        new CoapEncoder(), new CoapDecoder() //
                ), rq);

        client.setIoHandler(new Handler());

        reg.register(new AbstractResourceHandler() {
View Full Code Here

        BioUdpServer server = new BioUdpServer();
        final RequestFilter<CoapMessage, CoapMessage> rq = new RequestFilter<>();

        server.setFilters(new ProtocolCodecFilter<CoapMessage, ByteBuffer, Void, Void>(
                new CoapEncoder(), new CoapDecoder()), rq);
        // idle in 10 minute
        server.getSessionConfig().setIdleTimeInMillis(IdleStatus.READ_IDLE, 60 * 10_000);
        server.setIoHandler(new AbstractIoHandler() {

            long start = System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of org.apache.mina.coap.codec.CoapEncoder

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.