Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/handler/FirstConnector.java @ 384:bcdf5476b8e4
restructured-version
author | one@firefly.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Mon, 10 Nov 2008 22:16:37 +0900 |
parents | 4b87f89b3afd |
children | 1fca50ce3508 |
comparison
equal
deleted
inserted
replaced
383:6d48db302b07 | 384:bcdf5476b8e4 |
---|---|
1 package rep.handler; | 1 package rep.handler; |
2 | 2 |
3 import java.io.IOException; | 3 import java.io.IOException; |
4 | 4 |
5 import rep.REPCommand; | 5 import rep.REPCommand; |
6 import rep.ServerMainLoop; | |
6 import rep.Session; | 7 import rep.Session; |
7 import rep.SessionManager; | 8 import rep.SessionManager; |
8 import rep.channel.REPSelectionKey; | 9 import rep.channel.REPSelectionKey; |
9 import rep.channel.REPSocketChannel; | 10 import rep.channel.REPSocketChannel; |
10 | 11 |
26 * sm_join_ack | 27 * sm_join_ack |
27 */ | 28 */ |
28 REPNode fw; | 29 REPNode fw; |
29 REPSocketChannel<REPCommand> channel = key.channel1(); | 30 REPSocketChannel<REPCommand> channel = key.channel1(); |
30 REPCommand command = channel.read(); | 31 REPCommand command = channel.read(); |
31 SessionManager.logger.writeLog("FirstConnector: command = " + command); | 32 ServerMainLoop.logger.writeLog("FirstConnector: command = " + command); |
32 switch(command.cmd) { | 33 switch(command.cmd) { |
33 case SMCMD_JOIN: | 34 case SMCMD_JOIN: |
34 { | 35 { |
35 //どのSessionにも属さないエディタをリストに追加 | 36 //どのSessionにも属さないエディタをリストに追加 |
36 //エディタとchannelは1対1 (ではないかも) | 37 //エディタとchannelは1対1 (ではないかも) |
37 //エディタが新しくputする場合は新しくソケットを作る | 38 //エディタが新しくputする場合は新しくソケットを作る |
38 // 1対1でない場合は、multiplexerを挿めば良い | 39 // 1対1でない場合は、multiplexerを挿めば良い |
39 REPNode editor = manager.newEditor(channel); | 40 REPNode editor = manager.newEditor(channel); |
40 editor.setHost(manager.myHost); | 41 editor.setHost(manager.myHost()); |
41 command.eid = editor.eid; | 42 command.eid = editor.eid; |
42 command.sid = -1; | 43 command.sid = -1; |
43 editor.setSID(-1); | 44 editor.setSID(-1); |
44 fw = editor; | 45 fw = editor; |
45 break; | 46 break; |
72 break; | 73 break; |
73 default: throw new IOException(); | 74 default: throw new IOException(); |
74 } | 75 } |
75 //myHost を設定。 | 76 //myHost を設定。 |
76 //立ち上げ時にやるとlocalhostしか取れない | 77 //立ち上げ時にやるとlocalhostしか取れない |
77 if(manager.myHost == null) manager.setMyHostName(getLocalHostName()); | 78 if(manager.myHost() == null) manager.setMyHostName(getLocalHostName()); |
78 fw.setMode(command.cmd); | 79 fw.setMode(command.cmd); |
79 fw.setHost(manager.myHost); | 80 fw.setHost(manager.myHost()); |
80 manager.registerChannel(channel, fw); | 81 manager.registerChannel(channel, fw); |
81 manager.sessionManage(fw, command); | 82 manager.sessionManage(fw, command); |
82 | 83 |
83 } | 84 } |
84 | 85 |