123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package uraxis;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.ArrayList;
- import org.apache.xmlrpc.XmlRpcException;
- import org.apache.xmlrpc.client.XmlRpcClient;
- import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
- public class MyDaemonInterface {
- XmlRpcClient client;
- public MyDaemonInterface(String host, int port) {
- XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
- config.setEnabledForExtensions(true);
- try {
- config.setServerURL(new URL("http://" + host + ":" + port + "/RPC2"));
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- config.setConnectionTimeout(1000); //1s
- client = new XmlRpcClient();
- client.setConfig(config);
- }
- public boolean isReachable() {
- try {
- client.execute("get_title", new ArrayList<String>());
- return true;
- } catch (XmlRpcException e) {
- return false;
- }
- }
- public void setTitle(String title) {
- }
- public String getTitle() {
- return "";
- }
- public String getMessage(String name) {
- return "";
- }
- public boolean rel(int val) {
- try {
- client.execute("rel", new Object[]{String.valueOf(val)});
- return true;
- } catch (XmlRpcException e) {
- e.printStackTrace();
- return false;
- }
- }
- public boolean abs(int val) {
- try {
- client.execute("abs", new Object[]{String.valueOf(val)});
- return true;
- } catch (XmlRpcException e) {
- e.printStackTrace();
- return false;
- }
- }
- }
|