/** ** Main entry point for testing/debugging ** @param argv Comand-line arguments */ public static void main(String argv[]) { RTConfig.setCommandLineArgs(argv); String host = RTConfig.getString(ARG_HOST, null); int port = RTConfig.getInt(ARG_PORT, 0); /* send data */ if (RTConfig.hasProperty(ARG_SEND)) { if (StringTools.isBlank(host)) { Print.logError("Target host not specified"); usage(); } if (port <= 0) { Print.logError("Target port not specified"); usage(); } String dataStr = RTConfig.getString(ARG_SEND, "hello"); byte data[] = dataStr.startsWith("0x") ? StringTools.parseHex(dataStr, null) : dataStr.getBytes(); ClientSocketThread cst = new ClientSocketThread(host, port); try { cst.openSocket(); cst.socketWriteBytes(data); } catch (Throwable t) { Print.logException("Error", t); } finally { cst.closeSocket(); } System.exit(0); } /* receive data */ if (RTConfig.hasProperty(ARG_RECEIVE)) { if (port <= 0) { Print.logError("Target port not specified"); usage(); } if (!StringTools.isBlank(host)) { Print.logWarn("Specified 'host' will be ignored"); } Print.logError("Receive not yet implemented ..."); System.exit(99); } /* show usage */ usage(); }
/** ** Main entry point for testing/debugging ** @param argv Comand-line arguments */ public static void main(String argv[]) { RTConfig.setCommandLineArgs(argv); /* decode URI argument strings */ if (RTConfig.hasProperty(ARG_DECODE)) { String a = RTConfig.getString(ARG_DECODE, ""); String s = URIArg.decodeArg(new StringBuffer(), a).toString(); Print.sysPrintln("ASCII: " + s); System.exit(0); } /* encode Base64 strings */ if (RTConfig.hasProperty(ARG_ENCODE)) { String s = RTConfig.getString(ARG_ENCODE, ""); String a = URIArg.encodeArg(new StringBuffer(), s).toString(); Print.sysPrintln("Args: " + a); System.exit(0); } /* RTP decode */ if (RTConfig.hasProperty(ARG_RTPDEC)) { URIArg rtpUrl = new URIArg(RTConfig.getString(ARG_RTPDEC, "")); URIArg decUrl = rtpUrl.rtpDecode("rtp"); Print.sysPrintln("URL: " + decUrl.toString()); System.exit(0); } /* RTP encode */ if (RTConfig.hasProperty(ARG_RTPENC)) { URIArg decUrl = new URIArg(RTConfig.getString(ARG_RTPENC, "")); URIArg rtpUrl = decUrl.rtpEncode("rtp"); Print.sysPrintln("URL: " + rtpUrl.toString()); System.exit(0); } /* no options */ usage(); }