view rep/handler/REPHandlerImpl.java @ 218:827c439d0da4

*** empty log message ***
author pin
date Sun, 31 Aug 2008 07:53:28 +0900
parents 4d9b32666ed2
children dae90ded1bcd
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());
		REPCommand command = channel.read();

		manager.manage(channel, command);
	}

}