/*
 * The MIT License (MIT)
 * 
 * Copyright (c) 2016 - 2017
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.github.jtendermint.jabci;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.jtendermint.jabci.socket.TSocket;

public class StartupExampleDummy {
    private final static Logger LOG = LoggerFactory.getLogger(StartupExampleDummy.class);

    public static void main(String[] args) throws InterruptedException {
        new StartupExampleDummy().startExampleDummy();
    }

    public void startExampleDummy() throws InterruptedException {
        LOG.info("Starting Example Dummy");

        final TSocket sock = new TSocket();

        //// register TMSP-API listeners here:
        //// listeners can be TMSPAPI for accepting all messages or
        //// single interfaces like IInfo, IDeliverTX, etc... to only target specific cases
        // sock.registerListener(some_listeners);

        Thread mainThread = new Thread(sock::start);
        mainThread.setDaemon(true);
        mainThread.start();

        Wrapper<Boolean> killed = new Wrapper<Boolean>(false);

        int i = 0;
        while (!killed.value) {
            Thread.sleep(1000L);
            i++;

            if (i >= 10) {
                sock.stop();
                killed.value = true;
            }
        }

        System.out.println("killed");
        System.out.println("Process should terminate at this point");
    }

    public class Wrapper<K> {

        public K value;

        public Wrapper(K k) {
            value = k;
        }

    }

}

@@ -2087,32 +2087,23 @@
         
-Wrapper%3CB
+b
 oolean
-%3E
  killed 
@@ -2108,35 +2108,13 @@
 d = 
-new Wrapper%3CBoolean%3E(
 false
-)
 ;%0A%0A 
@@ -2153,22 +2153,16 @@
 (!killed
-.value
 ) %7B%0A    
@@ -2290,14 +2290,8 @@
 lled
-.value
  = t
@@ -2438,134 +2438,6 @@
   %7D%0A
-%0A    public class Wrapper%3CK%3E %7B%0A%0A        public K value;%0A%0A        public Wrapper(K k) %7B%0A            value = k;%0A        %7D%0A%0A    %7D%0A%0A
 %7D%0A

remove wrapper