# HG changeset patch # User one # Date 1324372174 -32400 # Node ID 56251926d766046a0543e4df4e0f69aa7264a866 # Parent d39930ff8758010df797a525bf20daf12e4d16cf update diff -r d39930ff8758 -r 56251926d766 .classpath --- a/.classpath Mon Dec 12 12:50:08 2011 +0900 +++ b/.classpath Tue Dec 20 18:09:34 2011 +0900 @@ -2,5 +2,6 @@ + diff -r d39930ff8758 -r 56251926d766 bin/myVncProxy/Child.class Binary file bin/myVncProxy/Child.class has changed diff -r d39930ff8758 -r 56251926d766 bin/myVncProxy/MyRfbProto.class Binary file bin/myVncProxy/MyRfbProto.class has changed diff -r d39930ff8758 -r 56251926d766 bin/myVncProxy/VncProxyService.class Binary file bin/myVncProxy/VncProxyService.class has changed diff -r d39930ff8758 -r 56251926d766 src/myVncClient/BroadCast.java --- a/src/myVncClient/BroadCast.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncClient/BroadCast.java Tue Dec 20 18:09:34 2011 +0900 @@ -6,7 +6,7 @@ import java.net.MulticastSocket; import java.net.UnknownHostException; -public class BroadCast implements Runnable { +public class BroadCast { final int BUFSIZE = 1024; final String MCASTADDR = "224.0.0.1"; final int PORT = 8183; @@ -41,7 +41,7 @@ e.printStackTrace(); } } - +/* @Override public void run() { createSocket(); @@ -54,4 +54,5 @@ } } } + */ } diff -r d39930ff8758 -r 56251926d766 src/myVncClient/EchoClient.java --- a/src/myVncClient/EchoClient.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncClient/EchoClient.java Tue Dec 20 18:09:34 2011 +0900 @@ -150,7 +150,7 @@ //if(!(checkRepetition.equals("skip")) || "1".equals(leaderflag)) { if(!(waitReply.checkPath())) { Thread.sleep(1000); - reConnectionMain(); + reConnectionMain(echoSocket); streamClose(); } //Thread.sleep(1000); @@ -182,7 +182,7 @@ try { sendDataProxy("2", parent,null); getProxyData(is); - reConnectionMain(); + reConnectionMain(echoSocket); streamClose(); } catch (UnknownHostException e) { System.err.println("Trying to connect to unknown host: " + e); @@ -238,7 +238,9 @@ return checkRepetition; } - void reConnectionMain() { + void reConnectionMain(Socket echoSocket) { + client.close(); + client.setClientSocket(echoSocket); client.init(); client.setEchoValue(this); client.getParentName(); diff -r d39930ff8758 -r 56251926d766 src/myVncClient/GetBroadCast.java --- a/src/myVncClient/GetBroadCast.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncClient/GetBroadCast.java Tue Dec 20 18:09:34 2011 +0900 @@ -39,6 +39,7 @@ void socketClose() { try { + text.unVisible(); server.close(); is.close(); } catch (IOException e) { diff -r d39930ff8758 -r 56251926d766 src/myVncClient/MyVncClient.java --- a/src/myVncClient/MyVncClient.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncClient/MyVncClient.java Tue Dec 20 18:09:34 2011 +0900 @@ -16,13 +16,13 @@ * */ private static final long serialVersionUID = 1L; - boolean inAnApplet = true; - boolean inSeparateFrame = false; - Socket clientSocket = null; - String parent, treenum; + private boolean inAnApplet = true; + private boolean inSeparateFrame = false; + private Socket clientSocket = null; + private String parent, treenum; private String leaderflag; - boolean runflag = false; - boolean first = true; + private boolean runflag = false; + private boolean first = true; private EchoClient echoValue; private int echoPort; @@ -45,6 +45,7 @@ private void runClient(String[] argv) { mainArgs = argv; + System.out.println(mainArgs.length); inAnApplet = false; inSeparateFrame = true; if(mainArgs.length == 0) { @@ -205,16 +206,24 @@ e1.printStackTrace(); } - if (counter >= 6) { + if (counter >= 3) { echoValue.openport(); echoValue.notfoundParent(); } echoValue.openport(); + /* + if(echoValue.notfoundParent()) { + break; + } + */ // runflag = echo.losthost(); + + if (echoValue.losthost()) { break; } + counter++; } diff -r d39930ff8758 -r 56251926d766 src/myVncClient/TextBox.java --- a/src/myVncClient/TextBox.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncClient/TextBox.java Tue Dec 20 18:09:34 2011 +0900 @@ -5,23 +5,24 @@ import java.awt.event.*; import java.util.ArrayList; -public class TextBox extends JFrame implements ActionListener { +public class TextBox extends JFrame implements ActionListener, ItemListener { private JPanel panel = new JPanel(); private JButton button = new JButton("Connect"); private TextField t1; private TextField t2; - private double width; - private double height; + private double width = 750; + private double height = 500; private JLabel label; private boolean flag; ArrayList temp = new ArrayList(); - private int counter=0; + private int counter = 0; + //private JCheckBox[] check = new JCheckBox[20]; private Checkbox[] check = new Checkbox[20]; - private boolean firstFlag=true; + private boolean firstFlag = true; private String hostAddress; private String port; - + private CheckboxGroup ch = new CheckboxGroup(); public void ipRegister() { setSize(); @@ -29,13 +30,11 @@ visible(); } - public TextBox() { setTitle("Informatin Connection Address"); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } - private void setSize() { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); @@ -51,6 +50,10 @@ setVisible(true); } + public void unVisible() { + setVisible(false); + } + private void setText() { t1 = new TextField("Address", 30); t2 = new TextField("5999", 5); @@ -63,81 +66,108 @@ contentPane.add(panel, BorderLayout.CENTER); contentPane.add(label, BorderLayout.SOUTH); } - - void checkBox(String str) { - CheckboxGroup ch = new CheckboxGroup(); - check[counter] = new Checkbox(str,ch,false); - check[counter].setBackground(new Color(0,153,255)); - panel.add(check[counter]); - panel.setLayout(new GridLayout(counter+2, 0)); - counter++; - } - - void setButton(){ - panel.add(button); - panel.setBackground(Color.blue); - button.addActionListener(this); - Container contentPane = getContentPane(); - contentPane.add(panel, BorderLayout.CENTER); - } - - String splitString(String str) { - String[] split = str.split("\\*");; - String comper; - if(split.length>4) { - split[4] = null; - } - comper = split[1]+split[3]; - if(firstFlag) { - temp.add(comper); - firstFlag = false; - return "port:"+split[0]+":host:"+split[1]+":proxy:"+split[3]; - } - for(int t=0;t= 20) { + reportWindow(); + visible(); + break; + } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } + i++; } return hostAddress; - //return t1.getText(); + // return t1.getText(); } - + public String getPort() { return port; - //return t2.getText(); + // return t2.getText(); } public void actionPerformed(ActionEvent e) { flag = true; - for(int t=0;t 4) { + split[4] = null; + } + comper = split[1] + split[3]; + if (firstFlag) { + temp.add(comper); + firstFlag = false; + return "port:" + split[0] + ":host:" + split[1] + ":proxy:" + split[3]; + } + for (int t = 0; t < temp.size(); t++) { + if (!(comper.equals(temp.get(t)))) { + if (t == temp.size() - 1) { + temp.add(comper); + return "port:" + split[0] + ":host:" + split[1] + ":proxy:" + split[3]; + } + } else { + break; + } + } + return null; + } + + @Override + public void itemStateChanged(ItemEvent e) { } } diff -r d39930ff8758 -r 56251926d766 src/myVncProxy/AcceptClient.java --- a/src/myVncProxy/AcceptClient.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncProxy/AcceptClient.java Tue Dec 20 18:09:34 2011 +0900 @@ -230,7 +230,6 @@ } class Child { - void reportLastNode(String hiddenchild, String newparent, String newtreenum, String newpnum, String newleaderflag, int i) throws IOException { @@ -238,15 +237,12 @@ Socket echoSocket; System.out.println(hiddenchild + "に接続します"); echoSocket = new Socket(hiddenchild, 10001 + (i + 1));// i+1は実験中に同じマシーンを使っていたのでportを変えて対応、本番時には取り除く予定。 - DataOutputStream os = new DataOutputStream( echoSocket.getOutputStream()); - os.writeBytes(newparent + "\n"); os.writeBytes(newpnum + "\n"); os.writeBytes(newtreenum + "\n"); os.writeBytes(newleaderflag + "\n"); - os.close(); } catch (UnknownHostException e) { System.err.println("Don't know about host: localhost"); @@ -254,6 +250,5 @@ System.err .println("Couldn't get I/O for the connection to: localhost"); } - } } \ No newline at end of file diff -r d39930ff8758 -r 56251926d766 src/myVncProxy/VncProxyService.java --- a/src/myVncProxy/VncProxyService.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/myVncProxy/VncProxyService.java Tue Dec 20 18:09:34 2011 +0900 @@ -192,14 +192,15 @@ v.init(); v.start_threads(); - //Thread.sleep(10000); - //rfb.is = v.rfb.is; - //rfb.os = v.rfb.os; - //rfb.initData = v.rfb.initData; + Thread.sleep(10000); + //rfb = v.rfb; + rfb.is = v.rfb.is; + rfb.os = v.rfb.os; + rfb.initData = v.rfb.initData; -// changeConnection(); + //changeConnection(); // doProtocolInitialisation(); - /* + //readParameters(); options = new OptionsNoFrame(this); recordingSync = new Object(); @@ -229,7 +230,7 @@ //acceptThread.changeRfb(rfb); //vc.rfb = rfb; //rfbThread.start(); -*/ + } /* diff -r d39930ff8758 -r 56251926d766 src/treeVnc/SelectType.java --- a/src/treeVnc/SelectType.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/treeVnc/SelectType.java Tue Dec 20 18:09:34 2011 +0900 @@ -54,7 +54,7 @@ setVisible(false); } - void setButton(){ + private void setButton(){ panel.add(button); panel.setBackground(Color.blue); button.addActionListener(this); @@ -63,7 +63,7 @@ } - void checkBox() { + private void checkBox() { CheckboxGroup ch = new CheckboxGroup(); check[0] = new Checkbox("Client",ch,false); check[0].setBackground(new Color(0,153,255)); diff -r d39930ff8758 -r 56251926d766 src/treeVnc/TreeVnc.java --- a/src/treeVnc/TreeVnc.java Mon Dec 12 12:50:08 2011 +0900 +++ b/src/treeVnc/TreeVnc.java Tue Dec 20 18:09:34 2011 +0900 @@ -3,28 +3,35 @@ import myVncClient.MyVncClient; import myVncProxy.VncProxyService; -; public class TreeVnc { public static void main(String[] argv) { - SelectType select = new SelectType(); - select.selectType(); - - while (select.wait) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + /* + * SelectType select = new SelectType(); select.selectType(); + * + * while (select.wait) { try { Thread.sleep(1000); } catch + * (InterruptedException e) { e.printStackTrace(); } } + * System.out.println("test"); + */ + if (argv.length == 0) { + System.out.println("client"); + MyVncClient client = new MyVncClient(); + client.treeVncClient(argv); + } else if(argv.length == 1) { + if ("-p".equals(argv[0])) { + System.out.println("proxy"); + String[] temp = new String[0]; + VncProxyService proxy = new VncProxyService(); + proxy.treeVncProxy(temp); + } else { + System.out.println("use : java -jar TreeVnc.jar (IpAddress) 5900"); } - System.out.println("test"); - - if (select.type) { - MyVncClient client = new MyVncClient(); - client.treeVncClient(argv); - } else { - VncProxyService proxy = new VncProxyService(); - proxy.treeVncProxy(argv); - } + } else if(argv.length==2) { + System.out.println("proxy"); + VncProxyService proxy = new VncProxyService(); + proxy.treeVncProxy(argv); + } else{ + System.out.println("use : java -jar TreeVnc.jar (IpAddress) 5900"); + } } }