changeset 17:4eda2dbb7fef

ProxyVncCanvas version 0.2
author e085711
date Sun, 17 Apr 2011 23:59:13 +0900
parents 549229fd7288
children ccad9909e0e2
files src/MyRfbProto.java src/ProxyVncCanvas.java src/VncCanvas.java
diffstat 3 files changed, 22 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/MyRfbProto.java	Sun Apr 17 21:25:57 2011 +0900
+++ b/src/MyRfbProto.java	Sun Apr 17 23:59:13 2011 +0900
@@ -103,9 +103,22 @@
 			sock.getOutputStream().write(initData);
 	}
 
-	void sendData(byte b[]) throws IOException{
-		for(Socket cli : cliList)
-			cli.getOutputStream().write(b, 0, b.length);		
+//	void sendData(byte b[]) throws IOException{
+	void sendData(byte b[]){
+		try{
+			for(Socket cli : cliList){
+				try{
+					cli.getOutputStream().write(b, 0, b.length);
+				}catch(IOException e){
+					// if socket closed
+					//				cliList.remove(cli);
+					cliList.remove(cli);
+					System.out.println("cliSize="+cliSize());
+				}
+			}
+		}catch(Exception e){
+			System.out.println("cliSize 0");
+		}
 	}	
 	boolean ready() throws IOException {
 		BufferedReader br = new BufferedReader(new InputStreamReader(is));
--- a/src/ProxyVncCanvas.java	Sun Apr 17 21:25:57 2011 +0900
+++ b/src/ProxyVncCanvas.java	Sun Apr 17 23:59:13 2011 +0900
@@ -349,7 +349,7 @@
 		rfb.initServSock(5550);
 
 		// single thread
-		/*
+/*
 		try {
 			// rfb.setSoTimeout(1000);
 			Socket newCli = rfb.accept();
@@ -358,10 +358,11 @@
 		} catch (IOException e) {
 		}
 */
+
 		// multi thread
 		Thread accept = new Thread(new acceptThread(rfb));
 		 accept.start();
-		 
+
 
 		while (true) {
 
@@ -376,7 +377,7 @@
 			System.out.println("encoding=" + encoding);
 			rfb.reset();
 
-			rfb.mark(rfb.available());
+			rfb.mark(10000000);
 
 			rfb.printNumBytesRead();
 			int bufSize = (int)rfb.getNumBytesRead();
--- a/src/VncCanvas.java	Sun Apr 17 21:25:57 2011 +0900
+++ b/src/VncCanvas.java	Sun Apr 17 23:59:13 2011 +0900
@@ -417,6 +417,7 @@
 			rfb.reset();
 
 //			rfb.mark(rfb.available());
+			rfb.mark(1000000);
 			System.out.println("rfb.available()="+rfb.available());
 
 			rfb.printNumBytesRead();
@@ -574,7 +575,7 @@
 			bufSize = rfb.getNumBytesRead() - bufSize;
 			System.out.println("bufSize="+bufSize);
 			
-//			rfb.bufResetSend((int)bufSize);
+			rfb.bufResetSend((int)bufSize);
 			if(rfb.available() < bufSize){
 				System.out.println("rfb.available() < bufSize");