Class OOCSIClient

java.lang.Object
nl.tue.id.oocsi.client.OOCSIClient
Direct Known Subclasses:
OOCSICommunicator

public class OOCSIClient
extends java.lang.Object
OOCSI client wrapper for socket client
Author:
matsfunk
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.util.Map<java.lang.String,​Handler> channels  
    protected java.lang.String name  
    protected SocketClient sc  
    protected java.util.Map<java.lang.String,​Responder> services  
    static java.lang.String VERSION  
  • Constructor Summary

    Constructors
    Constructor Description
    OOCSIClient()
    create OOCSI client with a RANDOM name as the system-wide handle
    OOCSIClient​(java.lang.String name)
    create OOCSI client with the given name as the system-wide handle
  • Method Summary

    Modifier and Type Method Description
    java.lang.String channels()
    retrieve the list of channels on the server
    java.lang.String channels​(java.lang.String channelName)
    retrieve the list of sub-channel of the channel with the given name on the server
    java.lang.String clients()
    retrieve the list of clients on the server
    boolean connect()
    connect to OOCSI network without a concrete server given, i.e., wait for multi-cast messages broadcasting a server to connect to
    boolean connect​(java.lang.String hostname, int port)
    connect to OOCSI network
    void disconnect()
    disconnect from OOCSI network
    java.lang.String getName()
    get name of this OOCSI client
    OOCSIDevice heyOOCSI()
    create an OOCSI device instance with the client's name that can be configured and then submitted to the OOCSI server
    OOCSIDevice heyOOCSI​(java.lang.String deviceName)
    create a named OOCSI device that can be configured and then submitted to the OOCSI server
    boolean isConnected()
    check connection to OOCSI network
    boolean isReconnect()
    retrieve whether we are still trying to reconnect, or whether we have given up on this connection (server, handle, etc.)
    void kill()
    kills the connection to OOCSI server this is for testing, do NOT use for normal operation
    void log​(java.lang.String message)
    logging of message on console (can be overridden by subclass)
    void reconnect()
    reconnects the connection to OOCSI server this is for testing, do NOT use for normal operation
    void register​(java.lang.String channelName, java.lang.String callName, Responder responder)
    register a responder with the socket client with a given handle "callName" on channel "channelName"
    void register​(java.lang.String callName, Responder responder)
    register a responder with the socket client with a given handle "callName"
    void register​(OOCSICall call)
    register a call with the socket client
    void send​(java.lang.String channelName, java.lang.String message)
    send a string message to the channel with the given name
    void send​(java.lang.String channelName, java.util.Map<java.lang.String,​java.lang.Object> data)
    send a composite message (map) to the channel with the given name
    void setReconnect​(boolean reconnect)
    set whether or not a reconnection attempt should be made if a connection fails
    void subscribe​(java.lang.String channelName, Handler handler)
    subscribe to the channel with the given name
    void subscribe​(Handler handler)
    subscribe to my own channel
    void unregister​(java.lang.String callName)
    unregister a responder with the socket client with a given handle "callName"
    void unregister​(java.lang.String channelName, java.lang.String callName)
    unregister a responder with the socket client with a given handle "callName" on channel "channelName"
    void unsubscribe​(java.lang.String channelName)
    unsubscribe from the channel with the given name

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • VERSION

      public static final java.lang.String VERSION
      See Also:
      Constant Field Values
    • sc

      protected SocketClient sc
    • name

      protected java.lang.String name
    • channels

      protected java.util.Map<java.lang.String,​Handler> channels
    • services

      protected java.util.Map<java.lang.String,​Responder> services
  • Constructor Details

    • OOCSIClient

      public OOCSIClient()
      create OOCSI client with a RANDOM name as the system-wide handle
    • OOCSIClient

      public OOCSIClient​(java.lang.String name)
      create OOCSI client with the given name as the system-wide handle
      Parameters:
      name -
  • Method Details

    • getName

      public java.lang.String getName()
      get name of this OOCSI client
      Returns:
    • connect

      public boolean connect()
      connect to OOCSI network without a concrete server given, i.e., wait for multi-cast messages broadcasting a server to connect to
      Returns:
    • connect

      public boolean connect​(java.lang.String hostname, int port)
      connect to OOCSI network
      Parameters:
      hostname -
      port -
      Returns:
    • isConnected

      public boolean isConnected()
      check connection to OOCSI network
      Returns:
    • disconnect

      public void disconnect()
      disconnect from OOCSI network
    • kill

      public void kill()
      kills the connection to OOCSI server this is for testing, do NOT use for normal operation
    • reconnect

      public void reconnect()
      reconnects the connection to OOCSI server this is for testing, do NOT use for normal operation
    • isReconnect

      public boolean isReconnect()
      retrieve whether we are still trying to reconnect, or whether we have given up on this connection (server, handle, etc.)
      Returns:
    • setReconnect

      public void setReconnect​(boolean reconnect)
      set whether or not a reconnection attempt should be made if a connection fails
      Parameters:
      reconnect -
    • subscribe

      public void subscribe​(java.lang.String channelName, Handler handler)
      subscribe to the channel with the given name
      Parameters:
      channelName -
      handler -
    • subscribe

      public void subscribe​(Handler handler)
      subscribe to my own channel
      Parameters:
      handler -
    • unsubscribe

      public void unsubscribe​(java.lang.String channelName)
      unsubscribe from the channel with the given name
      Parameters:
      channelName -
    • register

      public void register​(OOCSICall call)
      register a call with the socket client
      Parameters:
      call -
    • register

      public void register​(java.lang.String callName, Responder responder)
      register a responder with the socket client with a given handle "callName"
      Parameters:
      callName -
      responder -
    • register

      public void register​(java.lang.String channelName, java.lang.String callName, Responder responder)
      register a responder with the socket client with a given handle "callName" on channel "channelName"
      Parameters:
      channelName -
      callName -
      responder -
    • unregister

      public void unregister​(java.lang.String callName)
      unregister a responder with the socket client with a given handle "callName"
      Parameters:
      callName -
    • unregister

      public void unregister​(java.lang.String channelName, java.lang.String callName)
      unregister a responder with the socket client with a given handle "callName" on channel "channelName"
      Parameters:
      channelName -
      callName -
    • send

      public void send​(java.lang.String channelName, java.lang.String message)
      send a string message to the channel with the given name
      Parameters:
      channelName -
      message -
    • send

      public void send​(java.lang.String channelName, java.util.Map<java.lang.String,​java.lang.Object> data)
      send a composite message (map) to the channel with the given name
      Parameters:
      channelName -
      data -
    • heyOOCSI

      public OOCSIDevice heyOOCSI()
      create an OOCSI device instance with the client's name that can be configured and then submitted to the OOCSI server
      Returns:
    • heyOOCSI

      public OOCSIDevice heyOOCSI​(java.lang.String deviceName)
      create a named OOCSI device that can be configured and then submitted to the OOCSI server
      Parameters:
      deviceName -
      Returns:
    • clients

      public java.lang.String clients()
      retrieve the list of clients on the server
      Returns:
    • channels

      public java.lang.String channels()
      retrieve the list of channels on the server
      Returns:
    • channels

      public java.lang.String channels​(java.lang.String channelName)
      retrieve the list of sub-channel of the channel with the given name on the server
      Parameters:
      channelName -
      Returns:
    • log

      public void log​(java.lang.String message)
      logging of message on console (can be overridden by subclass)
      Parameters:
      message -