changeset 97:44f5cdc63a76

don't create Rfb and VNC proxy on change server on root.
author oc
date Thu, 22 May 2014 19:45:59 +0900
parents 76e49dd9c9c5
children 8f4c45c1b396
files src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java src/viewer_swing/java/com/glavsoft/viewer/Viewer.java
diffstat 5 files changed, 28 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Thu May 22 17:42:31 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java	Thu May 22 19:45:59 2014 +0900
@@ -417,9 +417,9 @@
 
 	public void sendDesktopSizeChange() {
 		LinkedList<ByteBuffer> desktopSize = new LinkedList<ByteBuffer>();
-		int width = 0;
-		int height = 0;
-		desktopSize.add(new UpdateRectangleMessage(0,0, width , height, EncodingType.DESKTOP_SIZE).getMessage());
+		int width = context.getFbWidth();
+		int height = context.getFbHeight();
+		desktopSize.add(new UpdateRectangleMessage(0,0, width, height, EncodingType.DESKTOP_SIZE).getMessage());
 		multicastqueue.put(desktopSize);
 	}
 	
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java	Thu May 22 17:42:31 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/UpdateRectangleMessage.java	Thu May 22 19:45:59 2014 +0900
@@ -1,29 +1,31 @@
 package jp.ac.u_ryukyu.treevnc;
 
 import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
 
 import com.glavsoft.rfb.encoding.EncodingType;
 
 public class UpdateRectangleMessage {
 
-	private ByteBuffer msg = ByteBuffer.allocate(16);
+	private ByteBuffer msg = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN);
 
 	public UpdateRectangleMessage(int i, int j, int width, int height,
 			EncodingType desktopSize) {
+		
 		msg.put((byte) 0); // FrameBufferUpdate
 		msg.put((byte) 0); // padding
-		msg.putInt(1); // number of rectangle
-		msg.putInt(0);
-		msg.putInt(0);
-		msg.putInt(i);
-		msg.putInt(j);
+		msg.putShort((short) 1); // number of rectangle
+		msg.putShort((short) i);
+		msg.putShort((short) j);
+		msg.putShort((short) width);
+		msg.putShort((short) height);
 		msg.putInt(desktopSize.getId());
 		
 		msg.flip();
 
 	}
 	
-	public ByteBuffer getMessge(){
+	public ByteBuffer getMessage(){
 		return msg;
 	}
 
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java	Thu May 22 17:42:31 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/MyRfbProtoProxy.java	Thu May 22 19:45:59 2014 +0900
@@ -53,13 +53,10 @@
 	ExecutorService executor;
 
 	byte[] pngBytes;
-	// private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new
-	// MostRecentMultiCast<LinkedList<ByteBuffer>>(10);
-	// private MulticastQueue<LinkedList<ByteBuffer>> multicastqueue = new
-	// MulticastQueue<LinkedList<ByteBuffer>>();
+
 	private Inflater inflater = new Inflater();
 	private Deflater deflater = new Deflater();
-	// private Thread requestThread;
+
 	private RequestScreenThread rThread;
 	private Thread requestThread;
 	private int rangeX = 256; // screenRange XPosition
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Thu May 22 17:42:31 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java	Thu May 22 19:45:59 2014 +0900
@@ -94,6 +94,16 @@
 
 		}
 	}
+	
+	private void inhelitClients(VncProxyService vs, String hostName) {
+		myRfb.setReadyReconnect(false);
+		setConnectionParam(hostName,vncport);
+		isApplet = true;
+		this.setNoConnection(false);
+		run();
+		firstTime = false;
+		createConnectionAndStart();
+	}
 
 	public void createConnectionAndStart() {
 		Thread thread;
@@ -201,26 +211,6 @@
 
 	}
 
-	private void sendReconnection(LinkedList<String> clientList,
-			String host, String port) throws UnknownHostException, IOException {
-		boolean passFlag = false;
-		int counter = 0;
-		for (String client : clientList) {
-			if (passFlag) {
-				Socket echoSocket = new Socket(client, 10001);
-				DataOutputStream os = new DataOutputStream(
-						echoSocket.getOutputStream());
-				os.writeBytes("reconnection\n");
-				if(counter++ < clients.getTreeBranch())
-					os.writeBytes(port + "\n");
-				else 
-					os.writeBytes(5999 + "\n");
-				os.close();
-				echoSocket.close();
-			}
-			passFlag = true;
-		}
-	}
 
 	/**
 	 * chnageVNCServer is called when host change.
@@ -236,17 +226,12 @@
 	public void changeVNCServer(String hostName, int width, int height)
 			throws UnknownHostException, IOException, InterruptedException {
 		// sender and reader stop
-		VncProxyService newVps = new VncProxyService(this, hostName);
-		newVps.setFirstTime(false);
-		// newVps.fbWidth = width;
-		// newVps.fbHeight = height;
-		// run call and change workingProtocol
-		newVps.setConnectionParam(hostName, vncport);
-		newVps.initProxy1(hostName);
-		orderRecconection(newVps ,hostName);
-		socketClose();
+		inhelitClients(this, hostName);
+		orderRecconection(this, hostName);
 	}
 
+	
+
 	@Override
 	public void settingsChanged(SettingsChangedEvent event) {
 
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Thu May 22 17:42:31 2014 +0900
+++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java	Thu May 22 19:45:59 2014 +0900
@@ -332,102 +332,3 @@
 		cuiVersion = flag;
 	}
 }
-
-    
-	/*
-    @Override
-	public void run() {
-
-        final boolean hasJsch = checkJsch();
-        final boolean allowInteractive = allowAppletInteractiveConnections || ! isApplet;
-        connectionPresenter = new ConnectionPresenter(hasJsch, allowInteractive);
-        connectionPresenter.addModel("ConnectionParamsModel", connectionParams);
-        final ConnectionView connectionView = new ConnectionView(
-                Viewer.this, // appWindowListener
-                connectionPresenter, hasJsch);
-        connectionPresenter.addView(ConnectionPresenter.CONNECTION_VIEW, connectionView);
-        if (isApplet) {
-            connectionPresenter.addView("AppletStatusStringView", new View() {
-                @Override
-                public void showView() { / }
-                @Override
-                public void closeView() {  }
-                @SuppressWarnings("UnusedDeclaration")
-                public void setMessage(String message) {
-                    Viewer.this.getAppletContext().showStatus(message);
-                }
-            });
-        }
-		if (forceReconnection) {
-			System.out.println("error10#####################");
-			connectionManager.showReconnectDialog("Connection lost", reconnectionReason);
-			forceReconnection = false;
-		}
-
-	
-		tryAgain = true;
-		while (tryAgain) {
-			if(workingSocket==null)
-				workingSocket = connectionManager.connectToHost(connectionParams, settings, rfb);
-			if (null == workingSocket) {
-				closeApp();
-				break;
-			}
-			logger.info("Connected");
-			System.out.println("connection-----------" + workingSocket.getInetAddress());
-			try {
-				workingSocket.setTcpNoDelay(true); // disable Nagle algorithm
-				Reader reader = new Reader(workingSocket.getInputStream());
-				Writer writer = new Writer(workingSocket.getOutputStream());
-
-				workingProtocol = new Protocol(reader, writer,
-						new PasswordChooser(passwordFromParams, connectionParams, containerFrame, this),
-						settings);
-				workingProtocol.handshake();
-
-                ClipboardControllerImpl clipboardController =
-		                new ClipboardControllerImpl(workingProtocol, settings.getRemoteCharsetName());
-				clipboardController.setEnabled(settings.isAllowClipboardTransfer());
-				settings.addListener(clipboardController);
-
-				surface = new Surface(workingProtocol, this, uiSettings.getScaleFactor());
-				settings.addListener(this);
-				uiSettings.addListener(surface);
-				containerFrame = createContainer();
-				connectionManager.setContainerFrame(containerFrame);
-				updateFrameTitle();
-				if(rfb != null) {
-					rfb.setViewer(this);
-					runAcceptThread();
-					rfb.setProtocolContext(workingProtocol);
-					rfb.notProxy();
-					workingProtocol.startTreeClientHandling(this,surface, clipboardController,rfb);
-				} else {
-					workingProtocol.startNormalHandling(this, surface, clipboardController);					
-				}
-				tryAgain = false;
-			} catch (UnsupportedProtocolVersionException e) {
-				connectionManager.showReconnectDialog("Unsupported Protocol Version", e.getMessage());
-				logger.severe(e.getMessage());
-			} catch (UnsupportedSecurityTypeException e) {
-				connectionManager.showReconnectDialog("Unsupported Security Type", e.getMessage());
-				logger.severe(e.getMessage());
-			} catch (AuthenticationFailedException e) {
-				passwordFromParams = null;
-				connectionManager.showReconnectDialog("Authentication Failed", e.getMessage());
-				logger.severe(e.getMessage());
-			} catch (TransportException e) {
-				connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage());
-				logger.severe(e.getMessage());
-			} catch (IOException e) {
-				connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage());
-				logger.severe(e.getMessage());
-			} catch (FatalException e) {
-				connectionManager.showReconnectDialog("Connection Error", "Connection Error" + ": " + e.getMessage());
-				logger.severe(e.getMessage());
-			}
-		}
-	}
-		*/
-
-