view src/pathfinder/mergetest/UsersSimulator.java @ 156:7ebd30e5e385 simulator-2008-8-26

*** empty log message ***
author pin
date Mon, 25 Aug 2008 15:53:03 +0900
parents 6a3c982bd72a
children
line wrap: on
line source

package pathfinder.mergetest;

import java.util.LinkedList;

import remoteeditor.command.REPCommand;

public class UsersSimulator extends Thread {
	private NetworkSimulator<REPCommand> ns;
	private LinkedList<REPCommand> cmds;
	private int eid;

	public UsersSimulator(NetworkSimulator<REPCommand> ns2, int _eid, LinkedList<REPCommand> _cmds) {
		ns = ns2;
		eid = _eid;
		cmds = _cmds;
	}

	public void run(){
		ns.writeLog("UsersSimulator start.", 1);
		ChannelSimulator<REPCommand> channel = ns.getAcceptedSession(eid);
		while(cmds.size()>0){
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			REPCommand cmd0 = createCmd();
			channel.write(cmd0);
		}

		ns.writeLog("UsersSimulator finish.", 1);
	}

	private REPCommand createCmd(){
		REPCommand cmd = cmds.remove(0);
		return cmd;
	}

	public void init() {
		// TODO Auto-generated method stub
		
	}

}