view rep/Forwarder.java @ 330:ddfc786811b9

*** empty log message ***
author kono
date Sun, 12 Oct 2008 04:23:57 +0900
parents 6ceb222570cb
children ef4afcae0c92
line wrap: on
line source

package rep;

import rep.channel.REPLogger;
import rep.channel.REPSocketChannel;
import rep.handler.PacketSet;

public class Forwarder extends EditorPlus {
	int seq = 0;
	Forwarder next;
	// REPCommands we sent to the next editor
	final int limit=100;
	REPLogger ns = REPLogger.singleton();
	SessionManager manager;
	
	public Forwarder(SessionManager manager) {
		this.manager = manager;
	}

	public int seq() {
		return seq++;
	}
	
	public void send(REPCommand command) {
		assert(command!=null);
		REPCommand c = new REPCommand(command);
		manager.addWriteQueue(new PacketSet(channel,null,  c));
	}
	
	public REPSocketChannel<REPCommand> getChannel() {
		return channel;
	}
	
	public void setChannel(REPSocketChannel<REPCommand> channel) {
		this.channel = channel;
	}

	public void setQuit2(REPCommand cmd) {
		send(cmd);
	}

	public void setNext(Forwarder next) {
		this.next = next;
	}
	
	public Forwarder getNextForwarder() {
		return next;
	}

	public boolean manage(REPCommand command) {
		send(command);
		return true;
	}

}