Mercurial > hg > Members > nobuyasu > tightVNCClient
changeset 44:034528dfb650
modify MuRfbProto.java VncCanvas.java. create sendDataToClient method.
author | e085711 |
---|---|
date | Sat, 09 Jul 2011 13:51:38 +0900 |
parents | 15e64e9154b5 |
children | 413df87d6f8f |
files | src/myVncClient/MyRfbProto.java src/myVncClient/VncCanvas.java |
diffstat | 2 files changed, 48 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/src/myVncClient/MyRfbProto.java Sat Jul 09 13:17:54 2011 +0900 +++ b/src/myVncClient/MyRfbProto.java Sat Jul 09 13:51:38 2011 +0900 @@ -33,7 +33,6 @@ private int rectH; private int encoding; private int zLen; - private int dataLen; private ServerSocket servSock; private int acceptPort; @@ -306,7 +305,39 @@ readFully(buffer); sendData(buffer); } - void readSendData()throws IOException{ + + void regiFramebufferUpdate()throws IOException{ + mark(20); + messageType = readU8(); + skipBytes(1); + rectangles = readU16(); + rectX = readU16(); + rectY = readU16(); + rectW = readU16(); + rectH = readU16(); + encoding = readU32(); + if(encoding == 16) + zLen = readU32(); + reset(); + } + int checkAndMark() throws IOException{ + int dataLen; + switch(encoding){ + case RfbProto.EncodingRaw: + dataLen = rectW * rectH * 4 + 16; + mark(dataLen); + break; + case RfbProto.EncodingZRLE: + dataLen = zLen+20; + mark(dataLen); + break; + default: + dataLen = 1000000; + mark(1000000); + } + return dataLen; + } + void readSendData(int dataLen)throws IOException{ byte buffer[] = new byte[dataLen]; readFully(buffer); reset(); @@ -321,37 +352,15 @@ }catch(Exception e){ } - } + } + void sendDataToClient() throws IOException { + regiFramebufferUpdate(); + int dataLen = checkAndMark(); + readSendData(dataLen); } - void regiFramebufferUpdate()throws IOException{ - mark(20); - messageType = readU8(); - skipBytes(1); - rectangles = readU16(); - rectX = readU16(); - rectY = readU16(); - rectW = readU16(); - rectH = readU16(); - encoding = readU32(); - if(encoding == 16) - zLen = readU32(); - reset(); - } - void checkAndMark() throws IOException{ - switch(encoding){ - case RfbProto.EncodingRaw: - dataLen = rectW * rectH * 4 + 16; - mark(dataLen); - break; - case RfbProto.EncodingZRLE: - dataLen = zLen+20; - mark(dataLen); - break; - default: - mark(1000000); - } - } + + BufferedImage createBufferedImage(Image img){ BufferedImage bimg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB );
--- a/src/myVncClient/VncCanvas.java Sat Jul 09 13:17:54 2011 +0900 +++ b/src/myVncClient/VncCanvas.java Sat Jul 09 13:51:38 2011 +0900 @@ -389,11 +389,14 @@ // System.out.println("\ncount=" + count); count++; - rfb.regiFramebufferUpdate(); - rfb.checkAndMark(); -// rfb.printFramebufferUpdate(); - rfb.readSendData(); - + // rfb.printFramebufferUpdate(); + + /* + * read Data from parents and send Data to Client. + * + */ + rfb.sendDataToClient(); + int bufSize = (int)rfb.getNumBytesRead();