# HG changeset patch # User e085711 # Date 1302884358 -32400 # Node ID c0ad3ecdf827204becf4f227aab0600ddcc39be5 # Parent 67caa17deb6f1502669b0fea646c792e1380b18f create method cliSize(). cliSize() is clisList.size() diff -r 67caa17deb6f -r c0ad3ecdf827 src/VncCanvas.java --- a/src/VncCanvas.java Sat Apr 16 01:08:39 2011 +0900 +++ b/src/VncCanvas.java Sat Apr 16 01:19:18 2011 +0900 @@ -380,45 +380,48 @@ long count = 0; while (true) { - + rfb.accept(); + + if (rfb.MYVNC) { - System.out.println("\ncount=" + count); - - int nBytes = 0; - rfb.mark(20); - int msgType = rfb.readU8(); - System.out.println("msgType=" + msgType); + if (rfb.cliSize() > 0) { + System.out.println("\ncount=" + count); - rfb.skipBytes(11); - int encoding = rfb.readU32(); - System.out.println("encoding=" + encoding); - nBytes = rfb.readU32(); - System.out.println("nBytes=" + nBytes); - rfb.reset(); + int nBytes = 0; + rfb.mark(20); + int msgType = rfb.readU8(); + System.out.println("msgType=" + msgType); - int len = rfb.available(); - System.out.println("rfb.available()=" + len); - if (len > 0) { + rfb.skipBytes(11); + int encoding = rfb.readU32(); + System.out.println("encoding=" + encoding); + nBytes = rfb.readU32(); + System.out.println("nBytes=" + nBytes); + rfb.reset(); - + int len = rfb.available(); + System.out.println("rfb.available()=" + len); + if (len > 0) { - if (nBytes > 0 & encoding == 16) {// 0より大きい(データがある)ときデータを転送 + if (nBytes > 0 & encoding == 16) {// 0より大きい(データがある)ときデータを転送 - rfb.mark(nBytes + 20); + rfb.mark(nBytes + 20); - byte b[] = new byte[nBytes + 20]; - // byte b[] = new byte[18+rfb.rnBytes]; - System.out.println("b.length=" + b.length); + byte b[] = new byte[nBytes + 20]; + // byte b[] = new byte[18+rfb.rnBytes]; + System.out.println("b.length=" + b.length); - rfb.readFully(b); + rfb.readFully(b); -// rfb.cliSock.getOutputStream().write(b, 0, b.length); - rfb.sendData(b); + // rfb.cliSock.getOutputStream().write(b, 0, + // b.length); + rfb.sendData(b); - try { - rfb.reset(); - } catch (IOException e) { - System.out.println(e); + try { + rfb.reset(); + } catch (IOException e) { + System.out.println(e); + } } } } @@ -453,11 +456,6 @@ int rx = rfb.updateRectX, ry = rfb.updateRectY; int rw = rfb.updateRectW, rh = rfb.updateRectH; - if (rfb.MYVNC) { - System.out.println("updateRectEncoding=" - + rfb.updateRectEncoding); - } - if (rfb.updateRectEncoding == rfb.EncodingLastRect) break; diff -r 67caa17deb6f -r c0ad3ecdf827 src/VncViewer.java --- a/src/VncViewer.java Sat Apr 16 01:08:39 2011 +0900 +++ b/src/VncViewer.java Sat Apr 16 01:19:18 2011 +0900 @@ -449,7 +449,8 @@ if (rfb.MYVNC) { rfb.initServSock(5550); - rfb.accept(); + rfb.setSoTimeout(10); +// rfb.accept(); } System.out.println("Desktop name is " + rfb.desktopName);