diff src/MyRfbProto.java @ 23:b51bb7bc0766

test update
author e085711
date Sun, 24 Apr 2011 16:48:39 +0900 (2011-04-24)
parents 361016476783
children
line wrap: on
line diff
--- a/src/MyRfbProto.java	Thu Apr 21 20:11:04 2011 +0900
+++ b/src/MyRfbProto.java	Sun Apr 24 16:48:39 2011 +0900
@@ -1,6 +1,7 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.net.BindException;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.util.LinkedList;
@@ -10,9 +11,14 @@
 
 	private int messageType;
 	private int rectangles;
+	private int rectX;
+	private int rectY;
+	private int rectW;
+	private int rectH;
 	private int encoding;
 
-	private ServerSocket servSock; 	
+	private ServerSocket servSock;
+	private int acceptPort;
 	private byte initData[];
 	private LinkedList <Socket> cliList;
 	
@@ -26,11 +32,27 @@
 		cliList = new LinkedList <Socket>();
 	}
 	
-	
 	void initServSock(int port) throws IOException{
 		servSock = new ServerSocket(port);
+		acceptPort = port;
 	}
+	void selectPort(){
+		int i = 5550;
+		while(true){
+			try{
+				initServSock(i);
+				break;
+			}catch(BindException e){
+				i++;
+				continue;
+			}catch(IOException e){
 
+			}
+		}
+	}
+	int getAcceptPort(){
+		return acceptPort;
+	}
 	void setSoTimeout(int num) throws IOException {
 		servSock.setSoTimeout(num);
 	}
@@ -147,15 +169,36 @@
 		messageType = readU8();
 		skipBytes(1);
 		rectangles = readU16();
-		skipBytes(8);
+		rectX = readU16();
+		rectY = readU16();
+		rectW = readU16();
+		rectH = readU16();
 		encoding = readU32();	
-		reset();	
+		reset();
 	}
+	void checkAndMark() throws IOException{
+		switch(encoding){
+		case RfbProto.EncodingRaw:
+			mark(rectW * rectH * 4 + 16);		
+			break;
+		default:
+			mark(1000000);
+		}
+	}
+	
 	void printFramebufferUpdate(){
 	
 		System.out.println("messageType=" + messageType);
 		System.out.println("rectangles="+rectangles);
 		System.out.println("encoding=" + encoding);
+		switch(encoding){
+		case RfbProto.EncodingRaw:
+			System.out.println("rectW * rectH * 4 + 16 =" + rectW * rectH * 4 + 16);
+			break;
+		default:
+			
+		
+		}
 	}