changeset 18:ccad9909e0e2

raw only version
author e085711
date Tue, 19 Apr 2011 16:46:27 +0900
parents 4eda2dbb7fef
children 3a8e75cb0743
files src/MyRfbProto.java src/ProxyVncCanvas.java src/VncCanvas.java src/ZlibInStream.java
diffstat 4 files changed, 29 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/src/MyRfbProto.java	Sun Apr 17 23:59:13 2011 +0900
+++ b/src/MyRfbProto.java	Tue Apr 19 16:46:27 2011 +0900
@@ -8,6 +8,10 @@
 
 class MyRfbProto extends RfbProto {
 
+	private int messageType;
+	private int rectangles;
+	private int encoding;
+
 	private ServerSocket servSock; 	
 	private byte initData[];
 	private LinkedList <Socket> cliList;
@@ -41,13 +45,11 @@
 	
 	void mark(int len) throws IOException {
 		is.mark(len);
-		System.out.println("is.mark");
 	}
 
 	void reset() throws IOException {
 		is.reset();
-		System.out.println("is.reset");
-	}
+ 	}
 
 	boolean markSupported() {
 		return is.markSupported();
@@ -113,9 +115,9 @@
 					// if socket closed
 					//				cliList.remove(cli);
 					cliList.remove(cli);
-					System.out.println("cliSize="+cliSize());
 				}
 			}
+		System.out.println("cliSize="+cliSize());
 		}catch(Exception e){
 			System.out.println("cliSize 0");
 		}
@@ -136,15 +138,25 @@
 		int len = size;
 		if(available() < size )
 			len = available();
-		System.out.println("len="+len);
 		byte buffer[] = new byte[len];
 		readFully(buffer);
 		sendData(buffer);
 	}
-	void resetNumBytesRead(){
-		numBytesRead = 0;
+	void regiFramebufferUpdate()throws IOException{
+		mark(16);
+		messageType = readU8();
+		skipBytes(1);
+		rectangles = readU16();
+		skipBytes(8);
+		encoding = readU32();	
+		reset();	
 	}
-
+	void printFramebufferUpdate(){
+	
+		System.out.println("messageType=" + messageType);
+		System.out.println("rectangles="+rectangles);
+		System.out.println("encoding=" + encoding);
+	}
 	
 	
 }
--- a/src/ProxyVncCanvas.java	Sun Apr 17 23:59:13 2011 +0900
+++ b/src/ProxyVncCanvas.java	Tue Apr 19 16:46:27 2011 +0900
@@ -369,17 +369,11 @@
 			System.out.println("\ncount=" + count);
 			count++;
 			
-			rfb.mark(16);
-			int mesageType = rfb.readU8();
-			System.out.println("mesageType=" + mesageType);
-			rfb.skipBytes(11);
-			int encoding = rfb.readU32();
-			System.out.println("encoding=" + encoding);
-			rfb.reset();
-
+			rfb.regiFramebufferUpdate();
+			rfb.printFramebufferUpdate();
+			
 			rfb.mark(10000000);
 
-			rfb.printNumBytesRead();
 			int bufSize = (int)rfb.getNumBytesRead();
 			
 			// Read message type from the server. 
@@ -440,7 +434,6 @@
 					case RfbProto.EncodingRaw:
 						statNumRectsRaw++;
 						handleRawRect(rx, ry, rw, rh);
-						rfb.printNumBytesRead();
 						break;
 					case RfbProto.EncodingCopyRect:
 						statNumRectsCopy++;
@@ -534,6 +527,7 @@
 				throw new Exception("Unknown RFB message type " + msgType);
 			}
 			bufSize = (int)rfb.getNumBytesRead() - bufSize;
+			System.out.println("bufSize="+bufSize);
 			rfb.bufResetSend(bufSize);
 		}
 	}
--- a/src/VncCanvas.java	Sun Apr 17 23:59:13 2011 +0900
+++ b/src/VncCanvas.java	Tue Apr 19 16:46:27 2011 +0900
@@ -401,26 +401,13 @@
 			count++;
 			System.out.println("ready rfb.available()="+rfb.available());			
 			
-			rfb.mark(20);
-			int messageType = rfb.readU8();
-			System.out.println("messageType=" + messageType);
-			rfb.skipBytes(1);
-			int rect = rfb.readU16();
-			System.out.println("rectangles="+rect);
-			rfb.skipBytes(8);
-			int encoding = rfb.readU32();
-			System.out.println("encoding=" + encoding);
-			if(encoding == 16){
-				int zlen = rfb.readU32();
-				System.out.println("zlen=" + zlen);
-			}
-			rfb.reset();
+			rfb.printFramebufferUpdate();
 
 //			rfb.mark(rfb.available());
 			rfb.mark(1000000);
 			System.out.println("rfb.available()="+rfb.available());
 
-			rfb.printNumBytesRead();
+//			rfb.printNumBytesRead();
 			long bufSize = rfb.getNumBytesRead();			
 			// Read message type from the server.
 			int msgType = rfb.readServerMessageType();
@@ -571,10 +558,8 @@
 			default:
 				throw new Exception("Unknown RFB message type " + msgType);
 			}
-			rfb.printNumBytesRead();
 			bufSize = rfb.getNumBytesRead() - bufSize;
 			System.out.println("bufSize="+bufSize);
-			
 			rfb.bufResetSend((int)bufSize);
 			if(rfb.available() < bufSize){
 				System.out.println("rfb.available() < bufSize");
@@ -897,7 +882,8 @@
 
 		if (zrleInStream == null)
 			zrleInStream = new ZlibInStream();
-
+//		System.out.println("zrleInStream.end="+zrleInStream.inflater.off);			
+		
 		int nBytes = rfb.readU32();
 		if (nBytes > 64 * 1024 * 1024)
 			throw new Exception("ZRLE decoder: illegal compressed data size");
--- a/src/ZlibInStream.java	Sun Apr 17 23:59:13 2011 +0900
+++ b/src/ZlibInStream.java	Tue Apr 19 16:46:27 2011 +0900
@@ -51,6 +51,7 @@
   }
 
   public int pos() { return ptrOffset + ptr; }
+  
 
   protected int overrun(int itemSize, int nItems) throws Exception {
     if (itemSize > bufSize)