diff options
Diffstat (limited to 'src/IvyClient.java')
-rwxr-xr-x | src/IvyClient.java | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/IvyClient.java b/src/IvyClient.java index 9555d8a..18a50f2 100755 --- a/src/IvyClient.java +++ b/src/IvyClient.java @@ -19,6 +19,9 @@ import gnu.regexp.*; * created for each remote client. * * CHANGELOG: + * 1.0.12: + * - right handling of IOExceptions in sendBuffer, the Client is removed from + * the bus * 1.0.10: * - removed the timeout bug eating all the CPU resources */ @@ -91,10 +94,13 @@ public class IvyClient implements Runnable { * allow the notification of regexp addition and deletion */ Enumeration getRegexps() { return regexp_text.elements(); } + int getAppPort() { return appPort ; } - /* perhaps we should perform some checking here */ - void sendRegexp(int id,String regexp) {send(AddRegexp,id,regexp);} + void sendRegexp(int id,String regexp) { + send(AddRegexp,id,regexp); /* perhaps we should perform some checking here */ + } + public void delRegexp(int id) {send( DelRegexp,id,"");} /** @@ -154,9 +160,7 @@ public class IvyClient implements Runnable { } catch (IvyException ie) { ie.printStackTrace(); } catch (InterruptedIOException ioe) { - // okay, nothing on the line - // do nothing but loop. It might be a bit resource-eating ... - System.out.println("DEBUG IvyClient: I have been interrupted"); + System.out.println("I have been interrupted. I'm about to leave my thread loop"); if (!gardefou) break; } } @@ -178,7 +182,12 @@ public class IvyClient implements Runnable { out.write(buffer.getBytes() ); out.flush(); } catch ( IOException e ) { - throw new IvyException("IvyClient.sendBuffer.write failed: "+e.getMessage()); + traceDebug("I can't send my message to this client. He probably left"); + try { + close("IO Exception"); + } catch (IOException ioe) { + throw new IvyException("close failed"+ioe.getMessage()); + } } } @@ -186,7 +195,6 @@ public class IvyClient implements Runnable { try { sendBuffer(type+" "+id+StartArg+arg); } catch (IvyException ie ) { - // TODO shoud fix the exception Handling here ... System.err.println("received an exception: " + ie.getMessage()); ie.printStackTrace(); } @@ -203,7 +211,6 @@ public class IvyClient implements Runnable { try { sendBuffer(buffer); } catch (IvyException ie ) { - // TODO shoud fix the exception Handling here ... System.err.println("received an exception: " + ie.getMessage()); ie.printStackTrace(); } @@ -274,7 +281,7 @@ public class IvyClient implements Runnable { break; case EndRegexp: bus.connect(this); - /* TODO ? + /* * the peer is perhaps not ready to handle this message * an assymetric processing should be written */ @@ -293,6 +300,7 @@ public class IvyClient implements Runnable { String[] tab = new String[v.size()]; for (int i=0;i<v.size();i++) { tab[i]=(String)v.elementAt(i); + // for developpemnt purposes // System.out.println(" *"+tab[i]+"* "+(tab[i]).length()); } bus.callCallback(this,msgId,tab); |