Datasheet

API in Java
91
API in Java
Summary
RouterOS API access library written in Java. This code is also capable to connect to IPv6 addresses.
Licensing
Code is provided as is and can be freely used freely. I, as a writer of code, am not responsible for anything that may
arise from use of this code.
Usage
Simple example how this can be used. T3apiView class is the interface class that is not supplied here and is
mentioned here only do show, how to start simple listener thread to receive the data replied by RouterOS
ApiConnection ret = new ApiConnection("192.168.88.1", 8728);
if (!ret.isConnected()) {
ret.start();
try {
ret.join();
if (ret.isConnected()) {
ret.login("admin", new char[0]);
}
} catch (InterruptedException ex) {
Logger.getLogger(T3apiView.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
aConn.sendCommand("/ip/address/print");
DataReceiver dataRec = new DataReceiver(aConn, this);
dataRec.start();
import libAPI.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author janisk
*/
public class DataReceiver extends Thread {
private ApiConnection aConn = null;
T3apiView t3A = null;
public DataReceiver(ApiConnection aConn, T3apiView t3A) {
this.aConn = aConn;
this.t3A = t3A;