Class JBusClient

java.lang.Object
java.lang.Thread
javaforce.jbus.JBusClient
All Implemented Interfaces:
Runnable

public class JBusClient extends Thread
  • Field Details

  • Constructor Details

    • JBusClient

      public JBusClient(String pack, Object obj)
      Creates new client.
      Parameters:
      pack - = client name in dot notation
      obj - = object with methods to invoke for RPC calls
  • Method Details

    • setDispatch

      public void setDispatch(Dispatch dispatch)
      Setup alternative message dispatch.
    • setDebug

      public void setDebug(boolean state)
      Enable logging exceptions to console.
    • setPort

      public void setPort(int port)
      Set server port. Must be called before start().
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • call

      public boolean call(String pack, String func, String args)
      Invoke function in another client.
      Parameters:
      pack - = other clients name (package)
      func - = method to invoke
      args - = comma list of arguments to pass ("strings" or integers only)
    • call

      public boolean call(String pfa)
      Invoke function in another client using condensed package.function.args format.
      Parameters:
      pfa - = package.function(args) There should be no quote around args (just around strings if there are any)
    • broadcast

      public boolean broadcast(String pack, String func, String args)
      Invoke function in all client matching package.
      Parameters:
      pack - = other clients name (package) if client.package.startsWith(pack) it will receive message
      func - = method to invoke
      args - = comma list of arguments to pass ("strings" or integers only)
    • ready

      public boolean ready()
      Returns if client is connected to server and ready.
    • close

      public void close()
      Closes connection to server.
    • quote

      public static String quote(String str)
      Quotes a string.
    • encodeString

      public static String encodeString(String in)
      Encode a string if it contains quotes, etc.
    • decodeString

      public static String decodeString(String in)
      Decode a string if it contains quotes, etc.
    • encodeByteArray

      public static String encodeByteArray(byte[] ba)
      Encode byte[] as a String.
    • decodeByteArray

      public static byte[] decodeByteArray(String str)
      Decode String as byte[]