import lava.net.common.UNL; import lava.net.common.Value; import lava.net.common.VariableModifier; import lava.net.psyc.PSYCPackage; import lava.net.psyc.PSYCMessageCenter; /** * **/ public class PSYCReceive implements PSYCPackage { /** * **/ private String[] methods = null; /** * **/ private PSYCMessageCenter center = null; /** * **/ public String getPackageName() { return ""; } /** * **/ public boolean uses() { return false; } /** * **/ public boolean understands() { return true; } /** * **/ public boolean wantsErrors() { return false; } /** * **/ public String[] getMethods() { return methods; } /** * **/ public String[] getVariables() { return null; } /** * **/ public void registerCenter(PSYCMessageCenter center) { this.center = center; } /** * **/ public void received(UNL source, String method, String body) { System.out.println(source + " --> " + method + "(" + // (body == null ? "[no more information]" : body) + ")"); if(method.equals(methods[methods.length - 1])) center.close(); } /** * **/ public void variableChanged(UNL source, VariableModifier modifier) { } /** * **/ public void reset(UNL source) { } /** * **/ public final static void main(String[] args) { if(args.length < 1) { System.out.println("Use arguments: [ ...]"); System.exit(0); } PSYCMessageCenter center = new PSYCMessageCenter(); PSYCReceive receiver = new PSYCReceive(); receiver.methods = args; center.addPackage(receiver); } }