Package net.sf.cindy

Examples of net.sf.cindy.SessionAcceptor


        echo = params.contains("-echo");
        handler = echo ? (SessionHandler) new EchoHandler()
                : new CachedFileHandler();
        sslc = params.contains("-secure") ? getSSLcontext() : null;

        SessionAcceptor acceptor = SessionFactory
                .createSessionAcceptor(SessionType.TCP);
        acceptor.setListenPort(port);
        acceptor.setAcceptorHandler(new SessionAcceptorHandler() {

            public void exceptionCaught(SessionAcceptor acceptor,
                    Throwable cause) {
                System.err.println(cause);
            }

            public void sessionAccepted(SessionAcceptor acceptor,
                    Session session) throws Exception {
                startSession(session);
            }
        });
        acceptor.start();
        if (acceptor.isStarted())
            print();
    }
View Full Code Here


        startService(19, new ChargenHandler(), "Chargen service");
    }

    private static void startService(int port, final SessionHandler handler,
            String serviceType) {
        SessionAcceptor acceptor = SessionFactory
                .createSessionAcceptor(SessionType.TCP);
        acceptor.setListenPort(port);
        acceptor.setAcceptorHandler(new SessionAcceptorHandlerAdapter() {

            public void sessionAccepted(SessionAcceptor acceptor,
                    Session session) throws Exception {
                session.setSessionHandler(handler);
                session.start();
            }

        });
        acceptor.start();
        if (acceptor.isStarted())
            System.out.println(serviceType + " listen on "
                    + acceptor.getListenAddress());
    }
View Full Code Here

            return null;
        }
    }

    public static void main(String[] args) throws IOException {
        SessionAcceptor acceptor = SessionFactory
                .createSessionAcceptor(SessionType.TCP);
        acceptor.setAcceptorHandler(new SessionAcceptorHandler() {

            public void exceptionCaught(SessionAcceptor acceptor,
                    Throwable cause) {
                cause.printStackTrace();
            }

            public void sessionAccepted(SessionAcceptor acceptor,
                    Session session) throws Exception {
                session.setPacketDecoder(new FileTransferMessageDecoder());
                session.setSessionHandler(new FileTransferHandler());
                session.start();
            }
        });
        acceptor.start();
        if (acceptor.isStarted())
            System.out.println("FileTransferServer listen on "
                    + acceptor.getListenAddress());
    }
View Full Code Here

                    .flip());
        }
    }

    public static void main(String[] args) throws Exception {
        SessionAcceptor acceptor = SessionFactory
                .createSessionAcceptor(SessionType.TCP);
        acceptor.setAcceptorHandler(new SessionAcceptorHandler() {

            public void sessionAccepted(SessionAcceptor acceptor,
                    Session session) throws Exception {
                session.setPacketDecoder(new ChatMessageDecoder());
                session.setPacketEncoder(new ChatMessageEncoder());
                session.addSessionFilter(new ChatLogFilter());
                session.setSessionHandler(new ChatHandler());
                session.start();
            }

            public void exceptionCaught(SessionAcceptor acceptor,
                    Throwable cause) {
                System.err.println(cause);
            }
        });
        acceptor.start();
        if (acceptor.isStarted())
            System.out.println("ChatServer listen on "
                    + acceptor.getListenAddress());
    }
View Full Code Here

        Class c = (Class) ACCEPTOR_MAP.get(type);
        if (c == null)
            throw new IllegalArgumentException("unsupported session type: "
                    + type);
        try {
            SessionAcceptor acceptor = (SessionAcceptor) c.newInstance();
            if (MBEAN_SERVER != null)
                MBEAN_SERVER.registerMBean(new JmxSessionAcceptor(acceptor),
                        getObjectName("SessionAcceptor-"
                                + ACCEPTOR_COUNTER.incrementAndGet()));
            return acceptor;
View Full Code Here

TOP

Related Classes of net.sf.cindy.SessionAcceptor

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.