157
|
1 package pathfinder.mergetest;
|
|
2
|
|
3 import java.util.LinkedList;
|
|
4
|
160
|
5 import pathfinder.mergetest.channels.ChannelSimulator;
|
|
6 import pathfinder.mergetest.channels.NetworkSimulator;
|
|
7
|
157
|
8 import remoteeditor.command.REPCommand;
|
|
9
|
|
10 public class UserSimulator extends Thread {
|
|
11 private NetworkSimulator<REPCommand> ns;
|
|
12 private LinkedList<REPCommand> cmds;
|
160
|
13 //private int eid;
|
|
14 private EditorSimulator editor;
|
157
|
15
|
|
16 public UserSimulator(NetworkSimulator<REPCommand> ns2, int _eid, LinkedList<REPCommand> _cmds) {
|
|
17 ns = ns2;
|
160
|
18 //eid = _eid;
|
157
|
19 cmds = _cmds;
|
|
20 }
|
|
21
|
|
22 public void run(){
|
|
23 ns.writeLog("UsersSimulator start.", 1);
|
160
|
24 ChannelSimulator<REPCommand> channel = editor.getChannelforUser();
|
157
|
25 while(cmds.size()>0){
|
|
26 // try {
|
|
27 // Thread.sleep(1000);
|
|
28 // } catch (InterruptedException e) {
|
|
29 // // TODO Auto-generated catch block
|
|
30 // e.printStackTrace();
|
|
31 // }
|
|
32 REPCommand cmd0 = createCmd();
|
|
33 channel.write(cmd0);
|
|
34 }
|
|
35
|
|
36 ns.writeLog("UsersSimulator finish.", 1);
|
|
37 }
|
|
38
|
|
39 private REPCommand createCmd(){
|
|
40 REPCommand cmd = cmds.remove(0);
|
|
41 return cmd;
|
|
42 }
|
|
43
|
|
44 public void init() {
|
|
45 // TODO Auto-generated method stub
|
|
46
|
|
47 }
|
|
48
|
|
49 }
|