Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/SessionManager.java @ 155:bbd2801d8ce0
*** empty log message ***
author | pin |
---|---|
date | Thu, 28 Aug 2008 15:39:20 +0900 |
parents | 2ce1a378da85 |
children | 5cc8cd48bded |
comparison
equal
deleted
inserted
replaced
154:fafbaaa0abd0 | 155:bbd2801d8ce0 |
---|---|
54 private boolean isMaster = true; | 54 private boolean isMaster = true; |
55 private EditorList ownEditorList; | 55 private EditorList ownEditorList; |
56 private List<Editor> editorList; | 56 private List<Editor> editorList; |
57 private String maxHost; | 57 private String maxHost; |
58 private boolean isSimulation; | 58 private boolean isSimulation; |
59 private List<PacketSet> packetSetList; | |
59 //private Set<SelectionKey> sessionList; | 60 //private Set<SelectionKey> sessionList; |
60 private static int temp_port; | 61 private static int temp_port; |
61 private static int send_port; | 62 private static int send_port; |
62 | 63 |
63 static final int DEFAULT_PORT = 8766; | 64 static final int DEFAULT_PORT = 8766; |
68 | 69 |
69 public void openSelector() throws IOException{ | 70 public void openSelector() throws IOException{ |
70 selector = REPSelector.open(); | 71 selector = REPSelector.open(); |
71 } | 72 } |
72 | 73 |
73 public void mainLoop(int port) throws InterruptedException, IOException { | 74 public void init(int port) throws InterruptedException, IOException { |
74 | 75 |
75 REPServerSocketChannel<REPCommand> ssc = REPServerSocketChannel.<REPCommand>open(); | 76 REPServerSocketChannel<REPCommand> ssc = REPServerSocketChannel.<REPCommand>open(); |
76 | |
77 ssc.configureBlocking(false); //reuse address 必須 | 77 ssc.configureBlocking(false); //reuse address 必須 |
78 | |
79 ssc.socket().setReuseAddress(true); | 78 ssc.socket().setReuseAddress(true); |
80 | |
81 ssc.socket().bind(new InetSocketAddress(port)); | 79 ssc.socket().bind(new InetSocketAddress(port)); |
82 ssc.register(selector, SelectionKey.OP_ACCEPT); | 80 ssc.register(selector, SelectionKey.OP_ACCEPT); |
83 | 81 |
84 | 82 |
85 sessionlist = new SessionList(); | 83 sessionlist = new SessionList(); |
86 sessionList = new LinkedList<Session>(); | 84 sessionList = new LinkedList<Session>(); |
87 smList = new SessionManagerList(); | 85 smList = new SessionManagerList(); |
88 ownEditorList = new EditorList(); | 86 ownEditorList = new EditorList(); |
89 editorList = new LinkedList<Editor>(); | 87 editorList = new LinkedList<Editor>(); |
90 | 88 packetSetList = new LinkedList<PacketSet>(); |
89 | |
90 // main loop | |
91 mainLoop(); | |
92 } | |
93 | |
94 private void mainLoop() throws IOException { | |
91 while(true){ | 95 while(true){ |
92 selector.select(); | 96 selector.select(); |
93 select(); | 97 select(); |
94 } | 98 } |
95 } | 99 } |
396 temp_port = port; | 400 temp_port = port; |
397 send_port = port_s; | 401 send_port = port_s; |
398 SessionManager sm = new SessionManager(port); | 402 SessionManager sm = new SessionManager(port); |
399 sm.openSelector(); | 403 sm.openSelector(); |
400 sm.openWindow(); | 404 sm.openWindow(); |
401 sm.mainLoop(port); | 405 sm.init(port); |
406 sm.mainLoop(); | |
402 } | 407 } |
403 | 408 |
404 private void openWindow() { | 409 private void openWindow() { |
405 Thread th = new Thread( gui ); | 410 Thread th = new Thread( gui ); |
406 th.start(); | 411 th.start(); |
496 | 501 |
497 } | 502 } |
498 | 503 |
499 public void addWaitingCommand(PacketSet set) { | 504 public void addWaitingCommand(PacketSet set) { |
500 // TODO Auto-generated method stub | 505 // TODO Auto-generated method stub |
501 | 506 packetSetList.add(set); |
502 } | 507 } |
503 | 508 |
504 public void undo() { | 509 public void undo() { |
505 // TODO Auto-generated method stub | 510 // TODO Auto-generated method stub |
506 | 511 |