view src/main/java/alice/daemon/OutboundTcpConnection.java @ 361:60eee1fb0fd3 multicast

create sender with udp
author sugi
date Thu, 15 May 2014 18:29:30 +0900
parents 8f71c3e6f11d
children aefbe41fcf12
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();
			}
		}
	}
	
}