Project

General

Profile

Revision 420

Added by Greg Tress about 16 years ago

Connection detection between the server and applet works. When disconnected, the user has the option to reconnect.

View differences:

ColonetServerInterface.java
163 163
		return false;
164 164
	}
165 165
	
166
	public String getLine () {
167
		if (this.isReady()) {
168
			try {
169
				return reader.readLine();
170
			} catch (IOException e) {
171
				return null;
172
			}
173
		} else {
174
		  return null;
175
		}
166
	public String getLine () throws IOException {
167
		return reader.readLine();
176 168
	}
177 169
  
178 170
	/**
......
200 192
		
201 193
		try {
202 194
			socket = new Socket(strHost, port);
195
			socket.setKeepAlive(true);
203 196
		} catch (UnknownHostException e) {
204 197
			log.append("Unknown host exception.\n");
205 198
			err("Unknown Host Exception");
......
228 221
	
229 222
	}
230 223
	
224
	public void disconnect () {
225
	    
226
	}
227
	
231 228
	/*
232 229
	*	sendString - only this method should actually write data to the output stream
233 230
	*/
......
460 457
			String line;
461 458
			while (true) { 
462 459
				try {
463
					line = getLine();
464
					if (line != null) {
465
						parseData(line);
466
					}
460
					line = reader.readLine();
461
					if (line == null)
462
					    throw new IOException();
463
					parseData(line);
467 464
					Thread.sleep(DATALISTENER_DELAY);
468 465
				} catch (InterruptedException e) {
469 466
					return;
470
				} 
467
				} catch (IOException e) {
468
			        disconnect();
469
				    colonet.disconnect();
470
				    return;
471
				}
471 472
			}
472 473
		}
473 474
		
......
500 501

  
501 502
	}
502 503

  
503
}
504
}

Also available in: Unified diff