view src/main/java/christie/daemon/OutboundTcpConnection.java @ 133:114e0e5b6564

fix prepartoclose
author akahori
date Tue, 25 Dec 2018 17:10:49 +0900
parents bf8ac57409af
children 2ecb3a93b8ae
line wrap: on
line source

package christie.daemon;

import christie.datagear.command.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();
            }
        }
    }
}