public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException { String name = args[0].val(); String endpoint = args[1].val(); int type = ZMQ.SUB; if (args.length == 3) { String stype = args[2].val().toUpperCase(); if (!"PUB".equals(stype) && !"SUB".equals(stype)) { throw new ConfigRuntimeException( "You must specify PUB or SUB" + " for comm_disconnect's third argument!", Exceptions.ExceptionType.NotFoundException, t); } if ("PUB".equals(stype)) { type = ZMQ.PUB; } } NodePoint node; try { if (type == ZMQ.PUB) { node = Tracking.getPub(name); } else { node = Tracking.getSub(name); } } catch (InvalidNameException ex) { throw new ConfigRuntimeException( "Invalid name " + name + " given to comm_disconnect!", Exceptions.ExceptionType.FormatException, t); } if (node == null) { throw new ConfigRuntimeException( "Unknown " + name + " " + " given to comm_disconnect!", Exceptions.ExceptionType.NotFoundException, t); } try { node.disconnect(endpoint); } catch (ZMQException e) { throw new ConfigRuntimeException( "Exception while disconnecting: " + e.getMessage(), Exceptions.ExceptionType.IOException, t); } return CNull.NULL; }
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException { String name = args[0].val(); String endpoint = args[1].val(); int type = ZMQ.PUB; if (args.length == 3) { String stype = args[2].val().toUpperCase(); if (!"PUB".equals(stype) && !"SUB".equals(stype)) { throw new ConfigRuntimeException( "You must specify PUB or SUB" + " for comm_listen's third argument!", Exceptions.ExceptionType.NotFoundException, t); } if ("SUB".equals(stype)) { type = ZMQ.SUB; } } NodePoint node; DaemonManager daemon = environment.getEnv(GlobalEnv.class).GetDaemonManager(); try { node = Tracking.getOrCreate(daemon, type, name); } catch (InvalidNameException ex) { throw new ConfigRuntimeException( "Invalid name " + name + " given to comm_listen!", Exceptions.ExceptionType.FormatException, t); } try { node.listen(endpoint); } catch (ZMQException e) { throw new ConfigRuntimeException( "Exception while listening: " + e.getMessage(), Exceptions.ExceptionType.IOException, t); } return CNull.NULL; }