MyDaemonInterface.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package uraxis;
  2. import java.net.MalformedURLException;
  3. import java.net.URL;
  4. import java.util.ArrayList;
  5. import org.apache.xmlrpc.XmlRpcException;
  6. import org.apache.xmlrpc.client.XmlRpcClient;
  7. import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
  8. public class MyDaemonInterface {
  9. XmlRpcClient client;
  10. public MyDaemonInterface(String host, int port) {
  11. XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
  12. config.setEnabledForExtensions(true);
  13. try {
  14. config.setServerURL(new URL("http://" + host + ":" + port + "/RPC2"));
  15. } catch (MalformedURLException e) {
  16. e.printStackTrace();
  17. }
  18. config.setConnectionTimeout(1000); //1s
  19. client = new XmlRpcClient();
  20. client.setConfig(config);
  21. }
  22. public boolean isReachable() {
  23. try {
  24. client.execute("get_title", new ArrayList<String>());
  25. return true;
  26. } catch (XmlRpcException e) {
  27. return false;
  28. }
  29. }
  30. public void setTitle(String title) {
  31. }
  32. public String getTitle() {
  33. return "";
  34. }
  35. public String getMessage(String name) {
  36. return "";
  37. }
  38. // public String getTitle() throws XmlRpcException, UnknownResponseException {
  39. // Object result = client.execute("get_title", new ArrayList<String>());
  40. // return processString(result);
  41. // }
  42. //
  43. // public String setTitle(String title) throws XmlRpcException, UnknownResponseException {
  44. // ArrayList<String> args = new ArrayList<String>();
  45. // args.add(title);
  46. // Object result = client.execute("set_title", args);
  47. // return processString(result);
  48. // }
  49. //
  50. // public String getMessage(String name) throws XmlRpcException, UnknownResponseException {
  51. // ArrayList<String> args = new ArrayList<String>();
  52. // args.add(name);
  53. // Object result = client.execute("get_message", args);
  54. // return processString(result);
  55. // }
  56. }