view src/main/java/christie/daemon/OutboundTcpConnection.java @ 13:bcd4f2c19185

don't work MessagePack unconvert for remote put
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Wed, 10 Jan 2018 20:37:47 +0900
parents b49a926cbdd9
children 5baccb8f7fbd
line wrap: on
line source

package christie.daemon;

import christie.codegear.Command;

public class OutboundTcpConnection extends Thread {

    Connection connection;

    public OutboundTcpConnection(Connection connection) {
        this.connection = connection;
    }

    public void run() {
        while (true) {
            try {
                Command cmd = connection.sendQueue.take();
                switch (cmd.type) {
                    case CLOSE:
                        connection.close();
                        return;
                    case FINISH:
                        System.exit(0);
                        return;
                    default:
                        break;
                }
                connection.write(cmd);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}