aboutsummaryrefslogtreecommitdiff
path: root/src/IvyClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/IvyClient.java')
-rwxr-xr-xsrc/IvyClient.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/IvyClient.java b/src/IvyClient.java
index 069a45b..4faeb00 100755
--- a/src/IvyClient.java
+++ b/src/IvyClient.java
@@ -100,6 +100,10 @@ public class IvyClient extends Thread {
RE regexp = (RE)regexp_in.get(key);
REMatch result = regexp.getMatch(message);
if ( result != null ) {
+ // it's just to check if matching went right.... It is right.
+ //String tmp="";
+ //for (int i=1;i<=regexp.getNumSubs();i++) { tmp+="'"+result.toString(i)+"' "; }
+ //System.out.println(">> matching "+regexp.getNumSubs()+" blocks "+tmp);
send(Msg,key,regexp.getNumSubs(),result);
count++;
}
@@ -160,14 +164,8 @@ public class IvyClient extends Thread {
break;
}
if(!st.hasMoreTokens()){close("Bad format no id '"+msg+"'");break;}
- /* IST */
token=st.nextToken(StartArg).trim();
- /*
- * TODO
- * this doesn't work on jdk1.3 !!!
- * the token equals " 3992", which provoques a NumberFormatException
- */
try {
msgid=Integer.valueOf(token);
} catch ( NumberFormatException e ) {
@@ -175,13 +173,20 @@ public class IvyClient extends Thread {
break;
}
String msgarg="";
- if (st.hasMoreTokens()) msgarg=st.nextToken("\n").trim();
+ // if (st.hasMoreTokens()) msgarg=st.nextToken("\n").trim();
+ if (st.hasMoreTokens()) msgarg=st.nextToken("\n");
+ // TODO: here is a bug !
+ // quick and dirty fix: I do the trimming by hand later on.
+ // (cf ref: This method may be used to trim whitespace from the
+ // beginning and end of a string; in fact, it trims all ASCII control characters as well.
+
/*
* second stage: process the message
*/
switch (msgtype) {
case Bye: break;
case AddRegexp:
+ msgarg.trim();
if ( bus.CheckRegexp(msgarg) ) {
try {
regexp_in.put(msgid,new RE(msgarg));
@@ -208,7 +213,7 @@ public class IvyClient extends Thread {
break;
case Msg:
try {
- bus.callCallback(this,msgid,msgarg);
+ bus.callCallback(this,msgid,msgarg.substring(1,msgarg.length()-1));
} catch (IvyException ie) {
// calling an inexistant callback
System.err.println("calling an inexistant callback, the caller must be wrong !");
@@ -226,6 +231,7 @@ public class IvyClient extends Thread {
}
break;
case DirectMsg:
+ msgarg.trim();
bus.directMessage( this, msgid.intValue(), msgarg );
break;
case Die: