-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
58 lines (47 loc) · 1.65 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package monto.broker.websocket;
import java.net.InetSocketAddress;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.zeromq.ZContext;
public class Main {
private static Options options = new Options();
private static HelpFormatter hf = new HelpFormatter();
public static void main(String[] args) throws ParseException, InterruptedException {
options
.addOption("source", true, "set zeromq source address")
.addOption("sink", true, "set zeromq sink address")
.addOption("debug", false, "enables debug output");
String srcAddress = null;
String snkAddress = null;
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
if (cmd.hasOption("source")) {
srcAddress = cmd.getOptionValue("source");
} else {
exit();
}
if (cmd.hasOption("sink")) {
snkAddress = cmd.getOptionValue("sink");
} else {
exit();
}
boolean debug = cmd.hasOption("debug");
ZContext context = new ZContext(1);
Thread wsd =
new Thread(
new WebSocketSendProxy(new InetSocketAddress(5003), srcAddress, context, debug),
"send-proxy");
wsd.start();
WebSocketReceiveProxy receiver =
new WebSocketReceiveProxy(new InetSocketAddress(5004), snkAddress, context, debug);
receiver.start();
}
private static void exit() {
hf.printHelp("", "", options, "", true);
System.exit(0);
}
}