Package nl.tue.id.oocsi.client
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
-
Constructor Summary
Constructors Constructor Description OOCSIClient()
create OOCSI client with a RANDOM name as the system-wide handleOOCSIClient(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 serverjava.lang.String
channels(java.lang.String channelName)
retrieve the list of sub-channel of the channel with the given name on the serverjava.lang.String
clients()
retrieve the list of clients on the serverboolean
connect()
connect to OOCSI network without a concrete server given, i.e., wait for multi-cast messages broadcasting a server to connect toboolean
connect(java.lang.String hostname, int port)
connect to OOCSI networkvoid
disconnect()
disconnect from OOCSI networkjava.lang.String
getName()
get name of this OOCSI clientOOCSIDevice
heyOOCSI()
create an OOCSI device instance with the client's name that can be configured and then submitted to the OOCSI serverOOCSIDevice
heyOOCSI(java.lang.String deviceName)
create a named OOCSI device that can be configured and then submitted to the OOCSI serverboolean
isConnected()
check connection to OOCSI networkboolean
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 operationvoid
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 operationvoid
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 clientvoid
send(java.lang.String channelName, java.lang.String message)
send a string message to the channel with the given namevoid
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 namevoid
setReconnect(boolean reconnect)
set whether or not a reconnection attempt should be made if a connection failsvoid
subscribe(java.lang.String channelName, Handler handler)
subscribe to the channel with the given namevoid
subscribe(Handler handler)
subscribe to my own channelvoid
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 nameMethods 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
-
name
protected java.lang.String name -
channels
-
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
subscribe to the channel with the given name- Parameters:
channelName
-handler
-
-
subscribe
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
register a call with the socket client- Parameters:
call
-
-
register
register a responder with the socket client with a given handle "callName"- Parameters:
callName
-responder
-
-
register
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
create an OOCSI device instance with the client's name that can be configured and then submitted to the OOCSI server- Returns:
-
heyOOCSI
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
-
-