view src/pathfinder/mergetest/UserSimulator.java @ 160:e9047957acc2

merge with pathfinder.simulator.*
author kent
date Tue, 26 Aug 2008 19:46:03 +0900
parents 1a2269c820df
children
line wrap: on
line source

package pathfinder.mergetest;

import java.util.LinkedList;

import pathfinder.mergetest.channels.ChannelSimulator;
import pathfinder.mergetest.channels.NetworkSimulator;

import remoteeditor.command.REPCommand;

public class UserSimulator extends Thread {
	private NetworkSimulator<REPCommand> ns;
	private LinkedList<REPCommand> cmds;
	//private int eid;
	private EditorSimulator editor;

	public UserSimulator(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 = editor.getChannelforUser();
		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
		
	}

}