package org.jvirtanen.parity.reporter;

import static org.jvirtanen.parity.util.Applications.*;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import org.jvirtanen.config.Configs;

class TradeReporter {

    public static void main(String[] args) {
        if (args.length != 1)
            usage("parity-reporter <configuration-file>");

        try {
            main(config(args[0]));
        } catch (ConfigException | FileNotFoundException e) {
            error(e);
        } catch (IOException e) {
            fatal(e);
        }
    }

    private static void main(Config config) throws IOException {
        InetAddress tradeReportMulticastInterface = Configs.getInetAddress(config, "trade-report.multicast-interface");
        InetAddress tradeReportMulticastGroup     = Configs.getInetAddress(config, "trade-report.multicast-group");
        int         tradeReportMulticastPort      = Configs.getPort(config, "trade-report.multicast-port");
        InetAddress tradeReportRequestAddress     = Configs.getInetAddress(config, "trade-report.request-address");
        int         tradeReportRequestPort        = Configs.getPort(config, "trade-report.request-port");

        TradeReportClient client = TradeReportClient.open(tradeReportMulticastInterface,
                new InetSocketAddress(tradeReportMulticastGroup, tradeReportMulticastPort),
                new InetSocketAddress(tradeReportRequestAddress, tradeReportRequestPort),
                new Display());

        while (true)
            client.receive();
    }

}

@@ -782,36 +782,25 @@
 InetAddress 
-tradeReportM
+m
 ulticastInte
@@ -895,28 +895,17 @@
 Address 
-tradeReportM
+m
 ulticast
@@ -1000,28 +1000,17 @@
         
-tradeReportM
+m
 ulticast
@@ -1097,28 +1097,17 @@
 Address 
-tradeReportR
+r
 equestAd
@@ -1202,28 +1202,17 @@
         
-tradeReportR
+r
 equestPo
@@ -1336,28 +1336,17 @@
 nt.open(
-tradeReportM
+m
 ulticast
@@ -1394,28 +1394,17 @@
 Address(
-tradeReportM
+m
 ulticast
@@ -1414,20 +1414,9 @@
 up, 
-tradeReportM
+m
 ulti
@@ -1464,28 +1464,17 @@
 Address(
-tradeReportR
+r
 equestAd
@@ -1484,20 +1484,9 @@
 ss, 
-tradeReportR
+r
 eque

Clean up trade reporter