Mercurial > hg > RemoteEditor > REPSessionManager
changeset 268:b69d22dbc6f1
*** empty log message ***
author | kono |
---|---|
date | Thu, 11 Sep 2008 15:00:16 +0900 |
parents | c513cf1ce9cc |
children | 6e0fa3415668 |
files | test/channeltest/testSeMa.java test/channeltest/testSeMaSlave.java |
diffstat | 2 files changed, 30 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/test/channeltest/testSeMa.java Thu Sep 11 14:39:32 2008 +0900 +++ b/test/channeltest/testSeMa.java Thu Sep 11 15:00:16 2008 +0900 @@ -70,12 +70,17 @@ ns.writeLog("accepts a client.", 1); }else if(key.isReadable()){ - REPSocketChannel<String> channel = (REPSocketChannel<String>) key.channel(pack); - String packet; - packet = channel.read(); - if (packet==null) continue; - ns.writeLog("receives String==> `"+packet+"\'", 1); - channel.write(this.getName()+": get `"+packet+"\'"); + try { + REPSocketChannel<String> channel = (REPSocketChannel<String>) key.channel(pack); + String packet; + packet = channel.read(); + if (packet==null) continue; + ns.writeLog("receives String==> `"+packet+"\'", 1); + channel.write(this.getName()+": get `"+packet+"\'"); + }catch (IOException e) { + ns.writeLog("channel "+ns+"closed."); + key.cancel(); + } } } }
--- a/test/channeltest/testSeMaSlave.java Thu Sep 11 14:39:32 2008 +0900 +++ b/test/channeltest/testSeMaSlave.java Thu Sep 11 15:00:16 2008 +0900 @@ -67,21 +67,26 @@ ns.writeLog("accepts a client.", 1); }else if(key.isReadable()){ - REPSocketChannel<String> channel = (REPSocketChannel<String>) key.channel(pack); - String packet = channel.read(); - if (packet==null) continue; - //if (channel==masterCH){ - if (packet.matches("^SeMa\\d.*")){ - ns.writeLog("receives String from master ==> `"+packet+"\'", 1); - for (ClientInfo ci: cis){ - if (!packet.matches(".*"+ci.str+".*")) continue; - ci.channel.write(this.getName()+": loopback master ==>`"+packet+"\'"); + try { + REPSocketChannel<String> channel = (REPSocketChannel<String>) key.channel(pack); + String packet = channel.read(); + if (packet==null) continue; + //if (channel==masterCH){ + if (packet.matches("^SeMa\\d.*")){ + ns.writeLog("receives String from master ==> `"+packet+"\'", 1); + for (ClientInfo ci: cis){ + if (!packet.matches(".*"+ci.str+".*")) continue; + ci.channel.write(this.getName()+": loopback master ==>`"+packet+"\'"); + } + }else{ + ns.writeLog("receives String==> `"+packet+"\'", 1); + //channlel.write("from "+this.getName()+": save"); + masterCH.write(this.getName()+": pass packet`"+packet+"\'"); + cis.add(new ClientInfo(packet, channel)); } - }else{ - ns.writeLog("receives String==> `"+packet+"\'", 1); - //channlel.write("from "+this.getName()+": save"); - masterCH.write(this.getName()+": pass packet`"+packet+"\'"); - cis.add(new ClientInfo(packet, channel)); + }catch (IOException e1) { + ns.writeLog("channel "+ns+" closed."); + key.cancel(); } } }