view src/main/java/alice/daemon/OutboundTcpConnection.java @ 393:38021fceabef draft multicast

test commit
author tatsuki
date Tue, 17 Jun 2014 17:39:47 +0900
parents 60eee1fb0fd3
children
line wrap: on
line source

package alice.daemon;

import alice.datasegment.Command;

public class OutboundTcpConnection extends Thread {
	
	public Connection connection;
	
	public OutboundTcpConnection(Connection connection) {
		this.connection = connection;
	}
	
	/**
	 * pipeline thread for transmission
	 */
	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();
			}
		}
	}
	
}