Mercurial > hg > Applications > TreeVNC
changeset 55:9fdb8ff88497
change parameter.
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/client/FramebufferUpdateRequestMessage.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/com/glavsoft/rfb/client/FramebufferUpdateRequestMessage.java Mon Dec 02 14:20:37 2013 +0900 @@ -24,6 +24,9 @@ package com.glavsoft.rfb.client; +import java.util.Timer; +import java.util.TimerTask; + import com.glavsoft.exceptions.TransportException; import com.glavsoft.transport.Writer; @@ -34,6 +37,8 @@ private final int width; private final int y; private final int x; + + private boolean sendFullScreenFlag; public FramebufferUpdateRequestMessage(int x, int y, int width, int height, boolean incremental) { @@ -42,12 +47,18 @@ this.width = width; this.height = height; this.incremental = incremental; + sendFullScreenRequest(); } @Override public void send(Writer writer) throws TransportException { writer.writeByte(FRAMEBUFFER_UPDATE_REQUEST); - writer.writeByte(incremental ? 1 : 0); + if(sendFullScreenFlag) { + writer.writeByte(0); + sendFullScreenFlag = false; + } else { + writer.writeByte(incremental ? 1 : 0); + } writer.writeInt16(x); writer.writeInt16(y); writer.writeInt16(width); @@ -61,5 +72,17 @@ + " width: " + width + " height: " + height + " incremental: " + incremental + "]"; } - + + public void sendFullScreenRequest() { + int sendFullScreenTimer = 5 * 1000; + TimerTask tt = new TimerTask() { + @Override + public void run() { + System.out.println("fullscreen"); + sendFullScreenFlag = true; + } + }; + Timer timer = new Timer(); + timer.schedule(tt, 0, sendFullScreenTimer); + } }
--- a/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/Protocol.java Mon Dec 02 14:20:37 2013 +0900 @@ -263,8 +263,7 @@ } @Override - public void sendRefreshMessage() { -// sendMessage(new FramebufferUpdateRequestMessage(0, 0, fbWidth, fbHeight, false)); + public void sendRefreshMessage() { sendMessage(new FramebufferUpdateRequestMessage(0, 0, 1006, 506, true)); logger.fine("sent: full FB Refresh"); }
--- a/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ReceiverTask.java Mon Dec 02 14:20:37 2013 +0900 @@ -86,7 +86,7 @@ renderer = repaintController.createRenderer(reader, context.getFbWidth(), context.getFbHeight(), context.getPixelFormat()); fullscreenFbUpdateIncrementalRequest = - new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); + new FramebufferUpdateRequestMessage(0, 0, context.getFbWidth(), context.getFbHeight(), true); } @Override
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/MyRfbProto.java Mon Dec 02 14:20:37 2013 +0900 @@ -230,6 +230,8 @@ echoSocket = new Socket(proxyAddr, 10001); DataOutputStream os = new DataOutputStream(echoSocket.getOutputStream()); os.writeBytes(echo.getMyAddress()+"\n"); + os.writeBytes(String.valueOf(echo.client.getFrameWidth())+"\n"); + os.writeBytes(String.valueOf(echo.client.getFrameHeight())+"\n"); System.out.println("---------push-------"); // os.writeBytes("1240\n"); // os.writeBytes("880\n");
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/EchoClient.java Mon Dec 02 14:20:37 2013 +0900 @@ -14,7 +14,7 @@ private WaitReply waitReply; private Socket clientSocket = null; private int echoPort = 9999; - Viewer client; + public Viewer client; private String parentAddress; public String parentNum; public String treeNum;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetDataClient.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetDataClient.java Mon Dec 02 14:20:37 2013 +0900 @@ -27,34 +27,12 @@ void socketClose() { try { text.unVisible(); - //server.close(); after the modify is.close(); } catch (IOException e) { e.printStackTrace(); } } -/* - private int castInt(byte[] a) { - int value = 0; - ByteArrayInputStream bais = new ByteArrayInputStream(a); - DataInputStream dis = new DataInputStream(bais); - try { - value = dis.readInt(); - } catch (IOException e) { - } - System.out.println(value); - return value; - } - - private String castString(byte[] a) { - String recover = new String(a); - recover = recover.replace("¥n", ""); - recover = recover.trim(); - System.out.println(recover); - return recover; - } -*/ @Override public void run() { try { @@ -65,10 +43,8 @@ is = new BufferedReader(new InputStreamReader( socket.getInputStream())); proxyAddr = is.readLine(); -// text = new TextBoxClient(); if(proxyAddr!=null) text.checkBox(proxyAddr); - // TextBoxClient text = new TextBoxClient(); text.setButton(); text.visible(); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/GetHostClient.java Mon Dec 02 14:20:37 2013 +0900 @@ -30,8 +30,6 @@ public void sendData() { buf = str.getBytes(); - // System.out.println("strlen"+str.length()); - // System.out.println("str"+str); DatagramPacket sendPacket = new DatagramPacket(buf, str.length(), mAddr, PORT); try { @@ -45,18 +43,4 @@ createSocket(); sendData(); } -/* - @Override - public void run() { - createSocket(); - while (true) { - sendData(); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - System.out.println(e); - } - } - } - */ }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/TextBoxClient.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/TextBoxClient.java Mon Dec 02 14:20:37 2013 +0900 @@ -74,12 +74,10 @@ } public void checkBox(String str) { - // CheckboxGroup ch = new CheckboxGroup(); if (counter == 0) check[counter] = new Checkbox(str, true, ch); else check[counter] = new Checkbox(str, false, ch); - // check[counter].setBackground(new Color(0, 153, 255)); check[counter].addItemListener(this); panel.add(check[counter]); panel.setLayout(new GridLayout(counter + 2, 0)); @@ -88,26 +86,11 @@ } public void setButton() { - // check[counter] = new Checkbox("test display", false, ch); - // panel.add(check[counter]); panel.add(button); - // panel.setBackground(Color.blue); button.addActionListener(this); contentPane.add(panel, BorderLayout.CENTER); } - /* - private void reportWindow() { - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Container pane = getContentPane(); - JLabel label = new JLabel( - "Not found Proxy. If you use Client-mode you must set-up Proxy"); - label.setPreferredSize(new Dimension(580, 50)); - label.setFont(new Font("Arial", Font.PLAIN, 20)); - pane.add(label); - } - */ - public String getAddressOption() { while (!(flag)) { try { @@ -123,11 +106,6 @@ int i = 0; while (!(flag)) { if (i >= 50) { - /* - reportWindow(); - visible(); - break; - */ return "notFound"; } try { @@ -138,7 +116,6 @@ i++; } return hostAddress; - // return t1.getText(); } public String getPortOption() { @@ -147,20 +124,15 @@ public String getPort() { return port; - // return t2.getText(); } public void actionPerformed(ActionEvent e) { - System.out.println("Action"); flag = true; for (int t = 0; t < counter; t++) { if (check[t].getState()) { System.out.println(check[t].getLabel()); - // if(int t =0) setStatus(check[t].getLabel()); unVisible(); - // else - // setStatus() } } }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/client/WaitReply.java Mon Dec 02 14:20:37 2013 +0900 @@ -41,11 +41,9 @@ echo.client.close(); passflag = true; echo.client.setSocket(echo.createSocketForClient(clientSocket,true)); - //client.init(); echo.client.run(); echoServer.close(); - //report finished connection at server. - reportConnectionFinished(clientSocket); + //report finished connection to server. clientSocket.close(); }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/BroadCastProxy.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/BroadCastProxy.java Mon Dec 02 14:20:37 2013 +0900 @@ -21,6 +21,7 @@ socket = new Socket(addr, port); os = new PrintStream(socket.getOutputStream()); os.println(str); + System.out.println(str); os.close(); socket.close(); //break;
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/GetBroadCastProxy.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/GetBroadCastProxy.java Mon Dec 02 14:20:37 2013 +0900 @@ -14,8 +14,6 @@ static final String McastAddr = "224.0.0.1"; static final int Port = 8183; static final int BufSize = 1024; - private byte[] buf = new byte[BufSize]; - private byte[] resorve = new byte[BufSize]; private ByteArrayInputStream inputStream; private boolean stopFlag = false; private VncProxyService vps; @@ -29,12 +27,14 @@ } private synchronized void getData() { + byte[] buf = new byte[BufSize]; + byte[] resorve = new byte[BufSize]; try { InetAddress mAddr = InetAddress.getByName(McastAddr); MulticastSocket soc = new MulticastSocket(Port); DatagramPacket recvPacket = new DatagramPacket(buf, BufSize); soc.joinGroup(mAddr); - while (true) { + while (!stopFlag) { soc.receive(recvPacket); address = getAddress(recvPacket.getSocketAddress()); inputStream = new ByteArrayInputStream(recvPacket.getData()); @@ -63,24 +63,11 @@ str = str.substring(1,str.indexOf(":")); return str; } -/* - private int castBytoToInt(byte[] a) { - int value = 0; - ByteArrayInputStream bais = new ByteArrayInputStream(a); - DataInputStream dis = new DataInputStream(bais); - try { - value = dis.readInt(); - } catch (IOException e) { - } - System.out.println(value); - return value; - } -*/ + private String castString(byte[] a) { String recover = new String(a); - recover = recover.replace("¥n", ""); + recover = recover.replace("��n", ""); recover = recover.trim(); -// System.out.println(recover); return recover; } @@ -106,6 +93,4 @@ } return new String(addr.getHostAddress()); } - - }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/VncProxyService.java Mon Dec 02 14:20:37 2013 +0900 @@ -58,7 +58,6 @@ static VncProxyService currentVps; private int fbWidth = 0; private int fbHeight = 0; - // public AcceptClient acc; private void initProxy(Parser parser) { aClient = new AcceptClient(); @@ -139,7 +138,6 @@ public boolean run1() { - rfb = new MyRfbProtoProxy(); // getHostData(); if (forceReconnection) { @@ -149,9 +147,6 @@ } tryAgain = true; while (tryAgain) { - // connectionParams.hostName = arguments[0]; - // workingSocket = - // connectionManager.connectToTreeHost(connectionParams, settings); workingSocket = connectionManager.connectToHost(connectionParams, settings, rfb); if (null == workingSocket) { @@ -310,9 +305,11 @@ new InputStreamReader( clientSocket.getInputStream())); String newHostName = is.readLine(); + int width = Integer.parseInt(is.readLine()); + int height = Integer.parseInt(is.readLine()); // String screenSize = is.readLine(); if(permitChangeScreen()) { - changeVNCServer(newHostName); + changeVNCServer(newHostName,width,height); } else { continue; } @@ -337,8 +334,7 @@ workingSocket.close(); acceptThread.flag = true; getCast.setStopFlag(true); - // createThread.setStopFlag(true); - } catch (IOException e) {/* nop */ + } catch (IOException e) { /* nop */ } } @@ -355,7 +351,6 @@ private void createSocketAndSend(LinkedList<String> clientList, String host, String port) throws UnknownHostException, IOException { boolean passFlag = false; - int count = 0; for (String client : clientList) { if (passFlag) { Socket echoSocket; @@ -363,23 +358,29 @@ DataOutputStream os = new DataOutputStream( echoSocket.getOutputStream()); os.writeBytes("reconnection\n"); -// if(count++ < aClient.getTreeBranch()) os.writeBytes(port + "\n"); -// else -// os.writeBytes(5999 + "\n"); os.close(); } passFlag = true; } } - - public void changeVNCServer(String hostName) throws UnknownHostException, + + /** + * chnageVNCServer is called when host change. + * @param hostName HostAddress + * @param width FrameWidth + * @param height FrameHeight + */ + public void changeVNCServer(String hostName, int width, int height) throws UnknownHostException, IOException { // sender and reader stop VncProxyService newVps = new VncProxyService(this,hostName); +// newVps.fbWidth = width; +// newVps.fbHeight = height; // run call and change workingProtocol newVps.connectionParams.hostName = hostName; if (newVps.run1()) { + socketClose(); newVps.createConnectionAndStart(); newVps.createSocketAndSend(aClient.getList(), hostName, String.valueOf(newVps.opendPort)); } else {
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ChangeHost.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/server/state/ChangeHost.java Mon Dec 02 14:20:37 2013 +0900 @@ -41,7 +41,8 @@ BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); str = br.readLine(); - vps.changeVNCServer(str); + // param hostAddress,width,height + vps.changeVNCServer(str,1000,1000); } // vps.createConnectionAndStart(); // vps.aClient.setList(prevVps.aClient.getList());
--- a/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Tue Nov 19 15:29:04 2013 +0900 +++ b/src/viewer_swing/java/com/glavsoft/viewer/Viewer.java Mon Dec 02 14:20:37 2013 +0900 @@ -705,4 +705,11 @@ public void setOpenPort(int port) { connectionParams.portNumber = port; } + + public int getFrameWidth() { + return containerFrame.getWidth(); + } + public int getFrameHeight() { + return containerFrame.getHeight(); + } }