// Path: src/main/java/me/legrange/mikrotik/MikrotikApiException.java
// public class MikrotikApiException extends Exception {
// 
// 
//     /** 
//      * Create a new exception 
//      * @param msg The message
//      */
//     public MikrotikApiException(String msg) {
//         super(msg);
//     }
// 
//  
//     /** 
//      * Create a new exception 
//      * @param msg The message
//      * @param err The underlying cause 
//      */
//     public MikrotikApiException(String msg, Throwable err) {
//         super(msg, err);
//     }
// }
// 
// Path: src/main/java/me/legrange/mikrotik/ResultListener.java
// public interface ResultListener {
//     
//     /** receive data from router
//      * @param result The data received */
//     void receive(Map<String, String> result);
// 
//     /** called if the command associated with this listener experiences an error
//      * @param ex Exception encountered */
//     void error(MikrotikApiException ex);
//     
//     /** called when the command associated with this listener is done */
//     void completed();
//    
// }


import java.util.Map;
import me.legrange.mikrotik.MikrotikApiException;
import me.legrange.mikrotik.ResultListener;
package examples;


/**
 * Example 5: Asynchronous results, with error and completion. Run a command and receive results, errors and completion notification for it asynchronously with a ResponseListener
 *
 * @author gideon
 */
public class AsyncWithErrorHandling extends Example {

    public static void main(String... args) throws Exception {
        AsyncWithErrorHandling ex = new AsyncWithErrorHandling();
        ex.connect();
        ex.test();
        ex.disconnect();
    }

// Path: src/main/java/me/legrange/mikrotik/MikrotikApiException.java
// public class MikrotikApiException extends Exception {
// 
// 
//     /** 
//      * Create a new exception 
//      * @param msg The message
//      */
//     public MikrotikApiException(String msg) {
//         super(msg);
//     }
// 
//  
//     /** 
//      * Create a new exception 
//      * @param msg The message
//      * @param err The underlying cause 
//      */
//     public MikrotikApiException(String msg, Throwable err) {
//         super(msg, err);
//     }
// }
// 
// Path: src/main/java/me/legrange/mikrotik/ResultListener.java
// public interface ResultListener {
//     
//     /** receive data from router
//      * @param result The data received */
//     void receive(Map<String, String> result);
// 
//     /** called if the command associated with this listener experiences an error
//      * @param ex Exception encountered */
//     void error(MikrotikApiException ex);
//     
//     /** called when the command associated with this listener is done */
//     void completed();
//    
// }


// Path: src/main/java/examples/AsyncWithErrorHandling.java
import java.util.Map;
import me.legrange.mikrotik.MikrotikApiException;
import me.legrange.mikrotik.ResultListener;

package examples;


/**
 * Example 5: Asynchronous results, with error and completion. Run a command and receive results, errors and completion notification for it asynchronously with a ResponseListener
 *
 * @author gideon
 */
public class AsyncWithErrorHandling extends Example {

    public static void main(String... args) throws Exception {
        AsyncWithErrorHandling ex = new AsyncWithErrorHandling();
        ex.connect();
        ex.test();
        ex.disconnect();
    }

    private void test() throws MikrotikApiException, InterruptedException {