Mercurial > hg > Members > nobuyasu > tightVNCProxy
changeset 39:f399eec66846
send data:multi thread
author | e085711 |
---|---|
date | Sun, 05 Jun 2011 22:30:46 +0900 |
parents | 84c02a9ce3ea |
children | dd1321b67f95 |
files | build.xml src/myVncProxy/MyRfbProto.java src/myVncProxy/ProxyVncCanvas.java src/myVncProxy/VncCanvas.java |
diffstat | 4 files changed, 55 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/build.xml Wed May 18 15:58:49 2011 +0900 +++ b/build.xml Sun Jun 05 22:30:46 2011 +0900 @@ -13,7 +13,7 @@ <target name="compile"> - <javac srcdir="${source}" destdir="${dir}" /> + <javac encoding="UTF-8" srcdir="${source}" destdir="${dir}" /> </target> <target name="mkjar">
--- a/src/myVncProxy/MyRfbProto.java Wed May 18 15:58:49 2011 +0900 +++ b/src/myVncProxy/MyRfbProto.java Sun Jun 05 22:30:46 2011 +0900 @@ -16,6 +16,8 @@ import javax.imageio.ImageIO; +import org.omg.CORBA.portable.OutputStream; + class MyRfbProto extends RfbProto { @@ -27,12 +29,14 @@ private int rectH; private int encoding; private int zLen; + private int dataLen; private ServerSocket servSock; private int acceptPort; private byte initData[]; private LinkedList <Socket> cliListTmp; private LinkedList <Socket> cliList; + private LinkedList <Thread> sendThreads; boolean createBimgFlag; byte[] pngBytes; @@ -42,6 +46,7 @@ cliList = new LinkedList <Socket>(); cliListTmp = new LinkedList <Socket>(); createBimgFlag = false; + sendThreads = new LinkedList <Thread>(); } MyRfbProto(String h, int p) throws IOException { @@ -49,6 +54,7 @@ cliList = new LinkedList <Socket>(); cliListTmp = new LinkedList <Socket>(); createBimgFlag = false; + sendThreads = new LinkedList <Thread>(); } void initServSock(int port) throws IOException{ @@ -205,6 +211,42 @@ readFully(buffer); sendData(buffer); } + void readSendData()throws IOException { + byte buffer[] = new byte[dataLen]; + readFully(buffer); + reset(); + + LinkedList <Thread> threads; + threads = new LinkedList<Thread>(); + + for(Socket cli : cliList){ +// try{ +// OutputStream out = (OutputStream) cli.getOutputStream(); +// Thread th = new Thread(new SendThread(out, buffer)); + Thread th = new Thread(new SendThread(cli, buffer)); + threads.add(th); +/* + }catch(IOException e){ + // if socket closed + cliListTmp.remove(cli); + }catch(Exception e){ + + } +*/ + } + + for(Thread thread : threads){ + thread.start(); + } + try{ + for(Thread thread : threads){ + thread.join(); + } + }catch(InterruptedException e){ + + } + + } void regiFramebufferUpdate()throws IOException{ mark(20); messageType = readU8(); @@ -222,10 +264,12 @@ void checkAndMark() throws IOException{ switch(encoding){ case RfbProto.EncodingRaw: - mark(rectW * rectH * 4 + 16); + dataLen = rectW * rectH * 4 + 16; + mark(dataLen); break; case RfbProto.EncodingZRLE: - mark(zLen+20); + dataLen = zLen+20; + mark(dataLen); break; default: mark(1000000);
--- a/src/myVncProxy/ProxyVncCanvas.java Wed May 18 15:58:49 2011 +0900 +++ b/src/myVncProxy/ProxyVncCanvas.java Sun Jun 05 22:30:46 2011 +0900 @@ -376,13 +376,15 @@ long count = 0; while (true) { +// System.out.println("\ncount=" + count); -// System.out.println("\ncount=" + count); count++; rfb.regiFramebufferUpdate(); rfb.checkAndMark(); // rfb.printFramebufferUpdate(); + rfb.readSendData(); + int bufSize = (int)rfb.getNumBytesRead(); @@ -540,8 +542,10 @@ bufSize = (int)rfb.getNumBytesRead() - bufSize; // System.out.println("bufSize="+bufSize); - rfb.bufResetSend(bufSize); +// rfb.bufResetSend(bufSize); + + if(rfb.createBimgFlag){ // bimg = createBufferedImage(rawPixelsImage); bimg = createBufferedImage(memImage);
--- a/src/myVncProxy/VncCanvas.java Wed May 18 15:58:49 2011 +0900 +++ b/src/myVncProxy/VncCanvas.java Sun Jun 05 22:30:46 2011 +0900 @@ -53,9 +53,9 @@ Image memImage; Graphics memGraphics; - + Image rawPixelsImage; -// BufferedImage rawPixelsImage; +// BufferedImage rawPixelsImaage; BufferedImage bimg; MemoryImageSource pixelsSource;