Package org.apache.mina.transport.bio

Examples of org.apache.mina.transport.bio.BioUdpServer


     */
    @Override
    public void start(int port) throws IOException {
        UdpSessionConfig config = new DefaultUdpSessionConfig();
        config.setReadBufferSize(65536);
        udpServer = new BioUdpServer(config, null);
        udpServer.setIoHandler(new IoHandler() {
            @Override
            public void sessionOpened(IoSession session) {
                session.setAttribute(STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
            }
View Full Code Here


            public String getPath() {
                return "register";
            }
        });

        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();
            int count = 0;

            @Override
            public void messageReceived(IoSession session, Object message) {
                System.err.println("rcv : " + message);

                CoapMessage resp = reg.respond((CoapMessage) message, session);
                System.err.println("resp : " + resp);
                session.write(resp);
                count++;
                if (count >= 100_000) {
                    System.err.println("time for 100k msg : " + (System.currentTimeMillis() - start));
                    count = 0;
                    start = System.currentTimeMillis();
                }
            }

            @Override
            public void messageSent(IoSession session, Object message) {
                System.err.println("sent : " + message);
            }

            @Override
            public void sessionIdle(IoSession session, IdleStatus status) {
                System.err.println("idle closing");
                session.close(false);
            }
        });

        try {
            server.bind(5683);
            new Thread() {
                @Override
                public void run() {
                    for (;;) {
                        for (IoSession s : registration.values()) {
View Full Code Here

            public String getPath() {
                return "register";
            }
        });

        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();
            int count = 0;

            @Override
            public void messageReceived(IoSession session, Object message) {
                System.err.println("rcv : " + message);

                CoapMessage resp = reg.respond((CoapMessage) message, session);
                System.err.println("resp : " + resp);
                session.write(resp);
                count++;
                if (count >= 100_000) {
                    System.err.println("time for 100k msg : " + (System.currentTimeMillis() - start));
                    count = 0;
                    start = System.currentTimeMillis();
                }
            }

            @Override
            public void messageSent(IoSession session, Object message) {
                System.err.println("sent : " + message);
            }

            @Override
            public void sessionIdle(IoSession session, IdleStatus status) {
                System.err.println("idle closing");
                session.close(false);
            }
        });

        try {
            server.bind(5683);
            new Thread() {
                @Override
                public void run() {
                    for (;;) {
                        for (IoSession s : registration.values()) {
View Full Code Here

     */
    @Override
    public void start(int port) throws IOException {
        UdpSessionConfig config = new DefaultUdpSessionConfig();
        config.setReadBufferSize(65536);
        udpServer = new BioUdpServer(config, null);
        udpServer.setIoHandler(new IoHandler() {
            @Override
            public void sessionOpened(IoSession session) {
                session.setAttribute(STATE_ATTRIBUTE, State.WAIT_FOR_FIRST_BYTE_LENGTH);
            }
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.bio.BioUdpServer

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.