package meerkat.pollingstation;

import meerkat.protobuf.PollingStation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Laura on 3/20/2017.
 */
public class PollingStationToyRun {
    final Logger logger = LoggerFactory.getLogger(getClass());

    private static PollingStationScanner.Consumer scanner;
    private static final String CONTEXT_PATH = "/scan";
    private static final int PORT = 8080;

    public static void main(String [] args) throws Exception {
        System.err.println("Setting up Scanner WebApp!");

//        scanner = new ReceiverScanHandler(PORT, SUB_ADDRESS);
//
//            try {
//            scanner.start();
//        } catch (Exception e) {
//                e.printStackTrace();
//                System.err.println("Could not start server: " + e.getMessage());
//        }

        scanner = new PollingStationWebScanner(0, CONTEXT_PATH);
        PollingStation.ConnectionServerData serverData = scanner.start(false);


        PollingStationMainController controller = new PollingStationMainController();
        controller.init(scanner);

        Thread controllerThread = new Thread(controller);
        controllerThread.setName("Meerkat PS-Controller Thread");
//        Thread serverThread = new Thread(serverController);
//        serverThread.setName("Meerkat PS-ServerScanner Thread");

        controllerThread.start();
        serverThread.start();

    }
}
