comparison src/myVncClient/EchoClient.java @ 57:e65934744da8

update
author Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
date Fri, 29 Jul 2011 17:23:47 +0900
parents f2f4b0398f04
children 18a19d8a09f4
comparison
equal deleted inserted replaced
56:9f8463fb1d4d 57:e65934744da8
117 117
118 /** 118 /**
119 * Call at lost host 119 * Call at lost host
120 */ 120 */
121 boolean losthost() { 121 boolean losthost() {
122 String checkRepetition;
122 if (echoSocket != null && os != null && is != null) { 123 if (echoSocket != null && os != null && is != null) {
123 try { 124 try {
124 if(runflag){ 125 if(runflag){
125 return true; 126 return true;
126 } 127 }
127 // echoSocketの情報を呼び出す 128 // echoSocketの情報を呼び出す
128 if ("1".equals(leaderflag)) { 129 if ("1".equals(leaderflag)) {
129 senddataProxy("1",parent); 130 senddataProxy("1",parent,treenum);
130 } else { 131 } else {
131 senddataProxy("3",parent); 132 senddataProxy("3",parent,treenum);
132 } 133 }
133 134
134 if ((responseLine = is.readLine()) != null) { 135 if ((responseLine = is.readLine()) != null) {
135 System.out.println("Server: " + responseLine); 136 System.out.println("Server: " + responseLine);
136 } 137 }
137 if ((parent = is.readLine()) != null) { 138 if ((parent = is.readLine()) != null) {
138 System.out.println("parent: " + parent); 139 System.out.println("parent: " + parent);
139 } 140 }
140 141 if ((checkRepetition = is.readLine()) != null) {
141 142 System.out.println("checkRepetition: " + checkRepetition);
143 }
144 if(checkRepetition.equals("stop")){
145 return true;
146 }
142 147
143 /** 148 /**
144 * if ((value.treenum = is.readLine()) != null) { 149 * if ((value.treenum = is.readLine()) != null) {
145 * System.out.println("treenum: " + value.treenum); } 150 * System.out.println("treenum: " + value.treenum); }
146 */ 151 */
193 198
194 boolean notfoundParent() { 199 boolean notfoundParent() {
195 if (echoSocket != null && os != null && is != null) { 200 if (echoSocket != null && os != null && is != null) {
196 runflag = true; 201 runflag = true;
197 try { 202 try {
198 senddataProxy("2", parent); 203 senddataProxy("2", parent,null);
199 204
200 if ((responseLine = is.readLine()) != null) { 205 if ((responseLine = is.readLine()) != null) {
201 System.out.println("Server: " + responseLine); 206 System.out.println("Server: " + responseLine);
202 } 207 }
203 if ((parent = is.readLine()) != null) { 208 if ((parent = is.readLine()) != null) {
290 System.out.println(e); 295 System.out.println(e);
291 } 296 }
292 return this; 297 return this;
293 } 298 }
294 299
295 void senddataProxy(String type,String num) { 300 void senddataProxy(String type,String num,String treenum) {
296 try { 301 try {
297 os.writeBytes(type + "\n"); 302 if(treenum!=null) {
298 os.writeBytes(num + "\n"); 303 os.writeBytes(type + "\n");
304 os.writeBytes(num + "\n");
305 os.writeBytes(treenum + "\n");
306 } else {
307 os.writeBytes(type + "\n");
308 os.writeBytes(num + "\n");
309 }
299 310
300 } catch (UnknownHostException e) { 311 } catch (UnknownHostException e) {
301 System.err.println("Trying to connect to unknown host: " + e); 312 System.err.println("Trying to connect to unknown host: " + e);
302 } catch (IOException e) { 313 } catch (IOException e) {
303 System.err.println("IOException: " + e); 314 System.err.println("IOException: " + e);