public final class Client extends Object implements ISynchAsynchConnection
Modifier and Type | Field and Description |
---|---|
protected long |
closeTimeout |
protected ID |
containerID |
static long |
DEFAULT_CLOSE_TIMEOUT |
static int |
DEFAULT_MAX_BUFFER_MSG |
static int |
DEFAULT_RCVR_PRIORITY |
static int |
DEFAULT_SNDR_PRIORITY |
static int |
DEFAULT_WAIT_INTERVAL |
protected ISynchAsynchEventHandler |
handler |
protected ObjectInputStream |
inputStream |
protected boolean |
isClosing |
protected int |
keepAlive |
protected Thread |
keepAliveThread |
protected ObjectOutputStream |
outputStream |
protected Object |
outputStreamLock |
protected PingMessage |
ping |
protected Object |
pingLock |
protected PingResponseMessage |
pingResp |
protected Map |
properties |
static String |
PROTOCOL |
protected SimpleFIFOQueue |
queue |
protected Thread |
rcvThread |
protected Thread |
sendThread |
protected Socket |
socket |
protected boolean |
waitForPing |
Constructor and Description |
---|
Client(ISynchAsynchEventHandler handler,
int keepAlive) |
Client(Socket aSocket,
ObjectInputStream iStream,
ObjectOutputStream oStream,
ISynchAsynchEventHandler handler) |
Client(Socket aSocket,
ObjectInputStream iStream,
ObjectOutputStream oStream,
ISynchAsynchEventHandler handler,
int maxmsgs) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(IConnectionListener l)
Add comm layer event listener
|
Object |
connect(ID remote,
Object data,
int timeout)
Connect to a remote process
|
protected Socket |
createConnectSocket(URI remote,
int timeout) |
protected void |
debug(String msg) |
void |
disconnect()
Disconnect
|
Object |
getAdapter(Class clazz) |
ID |
getLocalID()
Get local ID for this connection
|
Object |
getOutputStreamLock() |
Map |
getProperties()
Get properties for this connection
|
boolean |
isConnected() |
boolean |
isStarted() |
protected URI |
parseRemoteID(ID remote) |
void |
queueObject(ID recipient,
Serializable obj) |
void |
removeListener(IConnectionListener l)
remove comm layer event listener
|
void |
sendAsynch(ID recipient,
byte[] obj)
Send data asynchronously.
|
void |
sendAsynch(ID recipient,
Object obj) |
Serializable |
sendObject(ID recipient,
Serializable obj) |
Object |
sendSynch(ID rec,
byte[] obj)
Send data synchronously, blocking until a result is received
|
Object |
sendSynch(ID rec,
Object obj) |
void |
setCloseTimeout(long t) |
void |
setProperties(Map props) |
void |
start()
Start connection
|
void |
stop()
Stop connection
|
protected void |
traceStack(String msg,
Throwable e) |
public static final String PROTOCOL
public static final int DEFAULT_SNDR_PRIORITY
public static final int DEFAULT_RCVR_PRIORITY
public static final long DEFAULT_CLOSE_TIMEOUT
public static final int DEFAULT_MAX_BUFFER_MSG
public static final int DEFAULT_WAIT_INTERVAL
protected Socket socket
protected ObjectOutputStream outputStream
protected ObjectInputStream inputStream
protected ISynchAsynchEventHandler handler
protected SimpleFIFOQueue queue
protected int keepAlive
protected Thread sendThread
protected Thread rcvThread
protected Thread keepAliveThread
protected boolean isClosing
protected boolean waitForPing
protected PingMessage ping
protected PingResponseMessage pingResp
protected long closeTimeout
protected Map properties
protected ID containerID
protected Object pingLock
protected final Object outputStreamLock
public Client(Socket aSocket, ObjectInputStream iStream, ObjectOutputStream oStream, ISynchAsynchEventHandler handler) throws IOException
IOException
public Client(Socket aSocket, ObjectInputStream iStream, ObjectOutputStream oStream, ISynchAsynchEventHandler handler, int maxmsgs) throws IOException
IOException
public Client(ISynchAsynchEventHandler handler, int keepAlive)
public ID getLocalID()
IConnection
getLocalID
in interface IConnection
public void removeListener(IConnectionListener l)
IConnection
removeListener
in interface IConnection
l
- the listener to removepublic void addListener(IConnectionListener l)
IConnection
addListener
in interface IConnection
l
- the listener to addpublic boolean isConnected()
isConnected
in interface IConnection
public boolean isStarted()
isStarted
in interface IConnection
protected Socket createConnectSocket(URI remote, int timeout) throws ECFException
remote
- remote URItimeout
- timeoutECFException
- if socket cannot be created for input parametersprotected URI parseRemoteID(ID remote) throws ECFException
remote
- the remtoe IDECFException
- if remote ID cannot be parsedpublic Object connect(ID remote, Object data, int timeout) throws ECFException
IConnection
connect
in interface IConnection
remote
- the identity of the remote to connect to. Must not be null
.data
- any data to send with the connection request (e.g. password or
other authentication data)timeout
- the timeout (in ms) for the connection to occurECFException
- thrown if some problem with connectpublic void setCloseTimeout(long t)
public void start()
IConnection
start
in interface IConnection
public void stop()
IConnection
stop
in interface IConnection
public void disconnect()
IConnection
disconnect
in interface IConnection
public void sendAsynch(ID recipient, byte[] obj) throws IOException
IAsynchConnection
sendAsynch
in interface IAsynchConnection
recipient
- the ID of the intended receiverobj
- the data to sendIOException
- thrown if data cannot be sent (e.g. disconnected)public void sendAsynch(ID recipient, Object obj) throws IOException
IOException
public void queueObject(ID recipient, Serializable obj) throws IOException
IOException
public Serializable sendObject(ID recipient, Serializable obj) throws IOException
IOException
public Object sendSynch(ID rec, Object obj) throws IOException
IOException
public Object sendSynch(ID rec, byte[] obj) throws IOException
ISynchConnection
sendSynch
in interface ISynchConnection
rec
- the receiver to receive the synchronous requestobj
- the data to sendIOException
- thrown if sending cannot occur (e.g. not connected)public Map getProperties()
IConnection
getProperties
in interface IConnection
public Object getAdapter(Class clazz)
getAdapter
in interface org.eclipse.core.runtime.IAdaptable
protected void debug(String msg)
public void setProperties(Map props)
public Object getOutputStreamLock()
Copyright © 2017 Eclipse Foundation. All rights reserved.