diff options
Diffstat (limited to 'src/Puppet.java')
-rw-r--r-- | src/Puppet.java | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/Puppet.java b/src/Puppet.java index 17844ea..c307e01 100644 --- a/src/Puppet.java +++ b/src/Puppet.java @@ -1,5 +1,5 @@ /** - * Part of a Ivy-level proxy + * Part of a Ivy-level proxy, still in development, DO NOT USE * * @author Yannick Jestin * @author <a href="http://www.tls.cena.fr/products/ivy/">http://www.tls.cena.fr/products/ivy/</a> @@ -7,6 +7,8 @@ * (c) CENA 1998-2004 * * CHANGELOG: + * 1.2.16 + * uses Protocol enum * 1.2.14 * - switch from gnu regexp (deprecated) to the built in java regexp * - add generic types to declarations @@ -49,13 +51,13 @@ class Puppet { bound.put(ghostId,localId); } public void receive(IvyClient ic,String args[]) { - StringBuffer tosend = new StringBuffer(IvyClient.Msg); + StringBuffer tosend = new StringBuffer(Protocol.MSG.value()); tosend.append(" "); tosend.append(ghostId); - tosend.append(IvyClient.StartArg); + tosend.append(Protocol.STARTARG); for (int i=0;i<args.length;i++) { tosend.append(args[i]); - tosend.append(IvyClient.EndArg); + tosend.append(Protocol.ENDARG); } sendGhost(tosend.toString()); } @@ -94,30 +96,30 @@ class Puppet { void parse(String s) throws IvyException { Matcher m; if (!(m=ivyProto.matcher(s)).matches()) { System.out.println("Puppet error, can't parse "+s); return; } - int pcode=Integer.parseInt(m.group(1)); + Protocol pcode=Protocol.fromString(m.group(1)); String pid=m.group(2); String args=m.group(3); trace("must parse code:"+pcode+" id:"+pid+" args:"+args); switch (pcode) { - case IvyClient.AddRegexp: // the Ghost's peer subscribes to something + case ADDREGEXP: // the Ghost's peer subscribes to something addRegexp(pid,args); break; - case IvyClient.DelRegexp: // the Ghost's peer unsubscribes to something + case DELREGEXP: // the Ghost's peer unsubscribes to something removeRegexp(pid); break; - case IvyClient.Bye: // the Ghost's peer disconnects gracefully + case BYE: // the Ghost's peer disconnects gracefully bus.stop(); // TODO end of the puppet ? break; - case IvyClient.Die: + case DIE: // the Ghost's peer wants to ... kill ProxyClient ? break; - case IvyClient.Msg: + case MSG: // the Ghost's peer sends a message to ProxyClient, with regard to one // of our subscriptions // TODO a qui le faire passer ? break; - case IvyClient.SchizoToken: + case SCHIZOTOKEN: appName = args; bus = new PuppetIvy(appName,appName+" fakeready",null); for ( String ghostId: regexps.keySet() )new ForwardMessenger(ghostId,regexps.get(ghostId)); @@ -125,11 +127,11 @@ class Puppet { trace("starting the bus on "+domain); bus.start(domain); break; - case IvyClient.Error: - case IvyClient.EndRegexp: - case IvyClient.DirectMsg: - case IvyClient.Ping: - case IvyClient.Pong: + case ERROR: + case ENDREGEXP: + case DIRECTMSG: + case PING: + case PONG: default: trace("unused Ivy protocol code "+pcode); } |