changeset 19:3faae4215cb3

MyRfbProto Interface
author one
date Fri, 13 Jan 2012 16:02:26 +0900
parents 8e58ebe352ad
children 20c53b836ff8
files bin/treeVnc/MyRfbProtoClient.class bin/treeVnc/MyRfbProtoProxy.class src/treeVnc/AcceptThread.java src/treeVnc/MyRfbProtoClient.java src/treeVnc/MyRfbProtoProxy.java
diffstat 5 files changed, 35 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
Binary file bin/treeVnc/MyRfbProtoClient.class has changed
Binary file bin/treeVnc/MyRfbProtoProxy.class has changed
--- a/src/treeVnc/AcceptThread.java	Fri Jan 13 13:51:39 2012 +0900
+++ b/src/treeVnc/AcceptThread.java	Fri Jan 13 16:02:26 2012 +0900
@@ -5,66 +5,38 @@
 import java.io.OutputStream;
 
 public class AcceptThread implements Runnable {
-        MyRfbProtoClient rfbc = null;
-        MyRfbProtoProxy  rfbp = null;
+        MyRfbProto rfb = null;
         byte[] imageBytes;
         int port;
         
-        AcceptThread(MyRfbProtoClient _rfb) {
-                rfbc = _rfb;
-        }
-        
-        AcceptThread(MyRfbProtoProxy _rfb) {
-            rfbp = _rfb;
-        }
-        
-        AcceptThread(MyRfbProtoClient _rfb, int p) {
-            rfbc = _rfb;
-            port = p;
-        }
-
-        AcceptThread(MyRfbProtoProxy _rfb, int p) {
-            rfbp = _rfb;
-            port = p;
-        }
-      
-        public void changeRfb(MyRfbProtoClient _rfb) {
-        	rfbc = _rfb;
-        }
-        
-        public void changeRfb(MyRfbProtoProxy _rfb) {
-        	rfbp = _rfb;
+        AcceptThread(MyRfbProto _rfb) {
+                rfb = _rfb;
         }
 
-        public void run() {
-        		if(rfbc != null) { 
-        			rfbc.selectPort(port);
-        		        		
-                while (true) {
-                        try {
-                                Socket newCli = rfbc.accept();
+
+        AcceptThread(MyRfbProto _rfb, int p) {
+            rfb = _rfb;
+            port = p;
+        }
+       
+	public void changeRfb(MyRfbProto _rfb) {
+		rfb = _rfb;
+	}
+
+	public void run() {
+		rfb.selectPort(port);
 
-                                OutputStream os = newCli.getOutputStream();
-                                InputStream is = newCli.getInputStream();
-                                rfbc.newClient(this, newCli, os, is);
-                        } catch (IOException e) {
-                                e.printStackTrace();
-                                System.out.println(e);
-                        }
-                }
-        } else {
-            while (true) {
-                try {
-                        Socket newCli = rfbp.accept();
+		while (true) {
+			try {
+				Socket newCli = rfb.accept();
 
-                        OutputStream os = newCli.getOutputStream();
-                        InputStream is = newCli.getInputStream();
-                        rfbp.newClient(this, newCli, os, is);
-                } catch (IOException e) {
-                        e.printStackTrace();
-                        System.out.println(e);
-                }
-        }
-        }
-    }	
+				OutputStream os = newCli.getOutputStream();
+				InputStream is = newCli.getInputStream();
+				rfb.newClient(this, newCli, os, is);
+			} catch (IOException e) {
+				e.printStackTrace();
+				System.out.println(e);
+			}
+		}
+	}
 }
--- a/src/treeVnc/MyRfbProtoClient.java	Fri Jan 13 13:51:39 2012 +0900
+++ b/src/treeVnc/MyRfbProtoClient.java	Fri Jan 13 16:02:26 2012 +0900
@@ -34,7 +34,7 @@
 import java.io.OutputStream;
 
 public
-class MyRfbProtoClient extends RfbProto {
+class MyRfbProtoClient extends RfbProto implements MyRfbProto {
 	final static String versionMsg_3_855 = "RFB 003.855\n";
 
 	/**
@@ -198,7 +198,7 @@
 	}
 
 	// 5550を開けるが、開いてないなら+1のポートを開ける。
-	void selectPort(int p) {
+	public void selectPort(int p) {
 		int port = p;
 		while (true) {
 			try {
@@ -222,7 +222,7 @@
 		servSock.setSoTimeout(num);
 	}
 
-	Socket accept() throws IOException {
+	public Socket accept() throws IOException {
 		return servSock.accept();
 	}
 
@@ -778,7 +778,7 @@
 		// But we have do inflation for all input data, so we have to do it here.
 	}
 
-	void newClient(AcceptThread acceptThread, final Socket newCli,
+	public void newClient(AcceptThread acceptThread, final Socket newCli,
 			final OutputStream os, final InputStream is) throws IOException {
 		// createBimgFlag = true;
 		// rfb.addSockTmp(newCli);
--- a/src/treeVnc/MyRfbProtoProxy.java	Fri Jan 13 13:51:39 2012 +0900
+++ b/src/treeVnc/MyRfbProtoProxy.java	Fri Jan 13 16:02:26 2012 +0900
@@ -33,7 +33,7 @@
 import java.io.OutputStream;
 
 public
-class MyRfbProtoProxy extends RfbProto {
+class MyRfbProtoProxy extends RfbProto implements MyRfbProto {
 	final static String versionMsg_3_855 = "RFB 003.855\n";
 	/**
 	 * CheckMillis is one of new msgType for RFB 3.855. 
@@ -169,7 +169,7 @@
 	/*
 	 *  default port number is 5999. 
 	 */
-	void selectPort(int p) {
+	public void selectPort(int p) {
 		if(servSock != null ) return ;
 		int port = p;
 		while (true) {
@@ -194,7 +194,7 @@
 		servSock.setSoTimeout(num);
 	}
 
-	Socket accept() throws IOException {
+	public Socket accept() throws IOException {
 		return servSock.accept();
 	}
 
@@ -766,7 +766,7 @@
 		// But we have do inflation for all input data, so we have to do it here.
 	}
 
-	void newClient(AcceptThread acceptThread, final Socket newCli,
+	public void newClient(AcceptThread acceptThread, final Socket newCli,
 			final OutputStream os, final InputStream is) throws IOException {
 		// createBimgFlag = true;
 		// rfb.addSockTmp(newCli);