view rep/handler/REPHandlerInMerge.java @ 313:0585fd2410b8 single-insert-command

Single Insert Command worked.
author kono
date Sun, 05 Oct 2008 22:36:24 +0900
parents c5be84d53c7f
children
line wrap: on
line source

package rep.handler;

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

public class REPHandlerInMerge implements REPHandler {

	private SessionManager manager;

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


	public void handle(REPSelectionKey<REPCommand> key) throws IOException {
		//マージ中のエディタの前のエディタのコマンドをWaitingListに追加する
		REPSocketChannel<REPCommand> channel = key.channel1();
		REPCommand command = channel.read();
		System.out.println("REPHandlerImpl.handle() : command = " + command);
		// if (manager.isMerging(command.sid()))...
		//    同じchannelで、merge中のsessionは一つは限らない。
		//    なので、sid をinstanceで持つのではだめ。
		Session s = manager.getSession(command.sid);
		Editor editor = s.getEditor(channel);
		manager.addWaitingCommand(new PacketSet(channel, editor, command));
	}

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