view rep/handler/REPHandlerImpl.java @ 307:e4b7af3fdf99

*** empty log message ***
author kono
date Sat, 04 Oct 2008 22:12:16 +0900
parents c35f01b5060f
children c5be84d53c7f
line wrap: on
line source

package rep.handler;

import java.io.IOException;
import rep.REPCommand;
import rep.SessionManager;
import rep.channel.REPSelectionKey;
import rep.channel.REPSocketChannel;

public class REPHandlerImpl implements REPHandler {

	private SessionManager manager;


	public REPHandlerImpl(SessionManager manager) {
		this.manager = manager;
	}

	public void handle(REPSelectionKey<REPCommand> key) throws IOException {
		REPSocketChannel<REPCommand> channel = key.channel1();
		System.out.println("REPHandlerImpl.handle() : channel = " + channel);
		
		REPCommand command = channel.read();
		System.out.println("REPHandlerImpl.handle() : command = " + command);

		manager.manage(channel, command);
	}

	public void cancel(REPSocketChannel<REPCommand> socketChannel) {
		manager.remove(socketChannel);
	}


}