Mercurial > hg > RemoteEditor > REPSessionManager
changeset 211:44d502851c9e
*** empty log message ***
author | kent |
---|---|
date | Sat, 30 Aug 2008 15:38:56 +0900 |
parents | 3e0cd34d625d |
children | e8f716498caf |
files | rep/channel/REPSocketChannel.java test/channeltest/StringPacker.java test/channeltest/testNetworkSimulator.java test/channeltest/testSeMa.java test/channeltest/testSeMaSlave.java |
diffstat | 5 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/channel/REPSocketChannel.java Sat Aug 30 14:35:53 2008 +0900 +++ b/rep/channel/REPSocketChannel.java Sat Aug 30 15:38:56 2008 +0900 @@ -113,6 +113,7 @@ } public boolean write(P p){ ByteBuffer bb = pack.packUConv(p); + if (bb==null) return true; try { while (bb.remaining() > 0 ){ sc.write(bb); @@ -140,8 +141,9 @@ @Override public SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException { - assert(false); - return null; + return sc.register(sel, ops); + //assert(false); + //return null; }
--- a/test/channeltest/StringPacker.java Sat Aug 30 14:35:53 2008 +0900 +++ b/test/channeltest/StringPacker.java Sat Aug 30 15:38:56 2008 +0900 @@ -21,6 +21,7 @@ int size; ByteBuffer blog = ByteBuffer.allocate(log.length()*5); // TODO どれくらいにしよう? + if (log.length()==0) return null; /* ヘッダ あとでもう一回書き直す */ blog.putInt(0); @@ -34,7 +35,7 @@ size = blog.position(); blog.rewind(); /* ヘッダ 文字列の長さ */ - blog.putInt(size); + blog.putInt(size-4); blog.rewind(); return blog; @@ -48,11 +49,14 @@ sc.read(bb); bb.rewind(); int size = bb.getInt(); + + if(size==0) return null; // Stringの読み込み bb = ByteBuffer.allocate(size*2); bb.limit(size); - sc.read(bb); + while(bb.remaining()>0) + sc.read(bb); // Stringに変換して返す bb.rewind();
--- a/test/channeltest/testNetworkSimulator.java Sat Aug 30 14:35:53 2008 +0900 +++ b/test/channeltest/testNetworkSimulator.java Sat Aug 30 15:38:56 2008 +0900 @@ -16,7 +16,7 @@ public static void main(String[] args){ REPServerSocketChannel.isSimulation = false; - testNetworkSimulator testns = new testNetworkSimulator(1, 2, 2); + testNetworkSimulator testns = new testNetworkSimulator(1, 3, 50); logger.setLogLevel(5); testns.startTest();
--- a/test/channeltest/testSeMa.java Sat Aug 30 14:35:53 2008 +0900 +++ b/test/channeltest/testSeMa.java Sat Aug 30 15:38:56 2008 +0900 @@ -74,6 +74,7 @@ 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+"\'"); }
--- a/test/channeltest/testSeMaSlave.java Sat Aug 30 14:35:53 2008 +0900 +++ b/test/channeltest/testSeMaSlave.java Sat Aug 30 15:38:56 2008 +0900 @@ -69,6 +69,7 @@ ns.writeLog("gets readable channel", 1); REPSocketChannel<String> channel = (REPSocketChannel<String>) key.channel(pack); String packet = channel.read(); + if (packet==null) continue; if (channel==masterCH){ ns.writeLog("receives String from master ==> `"+packet+"\'", 1); for (ClientInfo ci: cis){