view rep/handler/REPHandlerImpl.java @ 237:c52e0e831d91

*** empty log message ***
author pin
date Sun, 31 Aug 2008 19:33:23 +0900
parents dae90ded1bcd
children 6589b148dd13
line wrap: on
line source

package rep.handler;

import java.io.IOException;
import java.nio.channels.SelectableChannel;

import rep.REPCommand;
import rep.REPCommandPacker;
import rep.SessionManager;
import rep.channel.REPSelectionKey;
import rep.channel.REPSocketChannel;

public class REPHandlerImpl implements REPHandler {

	private SessionManager manager;


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

	@SuppressWarnings("unchecked")
	public void handle(REPSelectionKey<REPCommand> key) throws IOException {
		SelectableChannel s = key.channel();
		if(!(s instanceof REPSocketChannel) ){
			System.out.println("error");
		}
		REPSocketChannel<REPCommand> channel = (REPSocketChannel<REPCommand>) key.channel(new REPCommandPacker());
		System.out.println("REPHandlerImpl.handle() : channel = " + channel);
		
		REPCommand command = channel.read();
		System.out.println("REPHandlerImpl.handle() : command = " + command);

		manager.manage(channel, command);
	}

}