Package net.sf.cindy

Examples of net.sf.cindy.FutureListener


public class DaytimeHandler extends SessionHandlerAdapter {

    public void sessionStarted(Session session) throws Exception {
        ByteBuffer buffer = Charset.UTF8.encode(new Date().toString());
        Future future = session.flush(new DefaultPacket(buffer));
        future.addListener(new FutureListener() {

            public void futureCompleted(Future future) throws Exception {
                future.getSession().close();
            }
        });
View Full Code Here


        Future future = session.send(response); // send http header
        if (content != null)
            future = session.flush(new DefaultPacket(content)); // send content
        if (!keepAlive)
            future.addListener(new FutureListener() {

                public void futureCompleted(Future future) throws Exception {
                    future.getSession().close();
                }
            });
View Full Code Here

        response.setParam("Connection", keepAlive ? "keep-alive" : "close");
        response.setContent(header);

        Future future = session.send(response);
        if (!keepAlive)
            future.addListener(new FutureListener() {

                public void futureCompleted(Future future) throws Exception {
                    future.getSession().close();
                }
            });
View Full Code Here

                int readCount = buffer.read(fc);

                if (readCount == -1) { // end of file
                    buffer.release();
                    session.send(BufferFactory.allocate(0)).addListener(
                            new FutureListener() {

                                public void futureCompleted(Future future)
                                        throws Exception {
                                    future.getSession().close();
                                }
View Full Code Here

        session.send(new Integer(Integer.MAX_VALUE));
        session.send(new Double(Math.random()));
        session.send(new User("User 1", 20));

        // send object and close the session
        session.send("bye!").addListener(new FutureListener() {

            public void futureCompleted(Future future) throws Exception {
                future.getSession().close();
            }
        });
View Full Code Here

        send(session);
    }

    private void send(Session session) {
        session.flush(new DefaultPacket(DATA)).addListener(
                new FutureListener() {

                    public void futureCompleted(Future future) throws Exception {
                        if (future.isSucceeded())
                            send(future.getSession());
                    }
View Full Code Here

TOP

Related Classes of net.sf.cindy.FutureListener

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.