Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/SessionManager.java @ 364:c965ef2b5fd6
*** empty log message ***
author | kono |
---|---|
date | Mon, 20 Oct 2008 13:44:34 +0900 |
parents | 1a8856580d38 |
children | c432755c3555 |
comparison
equal
deleted
inserted
replaced
363:1a8856580d38 | 364:c965ef2b5fd6 |
---|---|
271 | 271 |
272 /* | 272 /* |
273 * After loop detection, we give up session manager join. | 273 * After loop detection, we give up session manager join. |
274 */ | 274 */ |
275 private void cancel_sm_join() { | 275 private void cancel_sm_join() { |
276 logger.writeLog("Loop detected "+this); | |
276 removeChannel(sm_join_channel); | 277 removeChannel(sm_join_channel); |
277 sm_join_channel=null; | 278 sm_join_channel=null; |
278 } | 279 } |
279 | 280 |
280 | 281 |
281 private void removeChannel(Forwarder channel) { | 282 private void removeChannel(Forwarder channel) { |
282 REPSelectionKey<REPCommand> key = channel.channel.keyFor1(selector); | 283 REPSelectionKey<REPCommand> key = channel.channel.keyFor1(selector); |
283 key.cancel(); | 284 key.cancel(); |
284 try { | 285 try { |
285 channel.channel.close(); | 286 channel.channel.close1(); |
286 } catch (IOException e) { | 287 } catch (IOException e) { |
287 } | 288 } |
288 } | 289 } |
289 | 290 |
290 | 291 |
316 * GUI から、呼ばれて、Session Managerに接続する。 | 317 * GUI から、呼ばれて、Session Managerに接続する。 |
317 * Host 名のSession Manager に SM_JOIN する。自分は、Session を持っていては | 318 * Host 名のSession Manager に SM_JOIN する。自分は、Session を持っていては |
318 * ならない。複数のSession Managerにjoinすることは出来ない。(NATを実装するまでは)。 | 319 * ならない。複数のSession Managerにjoinすることは出来ない。(NATを実装するまでは)。 |
319 * @param host | 320 * @param host |
320 */ | 321 */ |
321 public void connectSession(String host) { | 322 public void connectSession(String host, int port) { |
322 if (sm_join_channel!=null) return; | 323 if (sm_join_channel!=null) return; |
323 if (!sessionList.isEmpty()) return; | 324 if (!sessionList.isEmpty()) return; |
324 if (!smList.isMaster()) return; | 325 if (!smList.isMaster()) return; |
325 int port = parent_port; | |
326 /* | 326 /* |
327 * IPv6 対応では、複数のアドレスを取って、それのすべてに接続を試す必要が | 327 * IPv6 対応では、複数のアドレスを取って、それのすべてに接続を試す必要が |
328 * ある。 | 328 * ある。 |
329 */ | 329 */ |
330 InetSocketAddress addr = new InetSocketAddress(host, port); | 330 InetSocketAddress addr = new InetSocketAddress(host, port); |
335 Forwarder sm = new Forwarder(this); | 335 Forwarder sm = new Forwarder(this); |
336 registerChannel(sessionchannel, sm); | 336 registerChannel(sessionchannel, sm); |
337 sm_join(sm); | 337 sm_join(sm); |
338 }catch (IOException e) { | 338 }catch (IOException e) { |
339 } | 339 } |
340 } | |
341 | |
342 public void connectSession(String host) { | |
343 connectSession(host,parent_port); | |
340 } | 344 } |
341 | 345 |
342 /** | 346 /** |
343 * channel に SMCMD_SM_JOIN command を送る。 | 347 * channel に SMCMD_SM_JOIN command を送る。 |
344 * @param channel | 348 * @param channel |
788 | 792 |
789 public Session getSession(int sid) { | 793 public Session getSession(int sid) { |
790 return sessionList.get(sid); | 794 return sessionList.get(sid); |
791 } | 795 } |
792 | 796 |
797 | |
793 } | 798 } |