Class NetAltingConnectionClient
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.AltingConnectionClient
-
- org.jcsp.net2.NetAltingConnectionClient
-
- All Implemented Interfaces:
ConnectionClient,NetConnectionClient,Networked
public final class NetAltingConnectionClient extends AltingConnectionClient implements NetConnectionClient
-
-
Field Summary
Fields Modifier and Type Field Description private ConnectionDatadataprivate AltingChannelInputinprivate NetworkMessageFilter.FilterRxinputFilterprivate booleanisLocalprivate LinklinkConnectedToprivate ConnectionDatalocalConnectionprivate NetConnectionLocationlocalLocationprivate NetworkMessageFilter.FilterTxoutputFilterprivate NetConnectionLocationserverLocationprivate ChannelOutputtoLinkTX
-
Constructor Summary
Constructors Modifier Constructor Description privateNetAltingConnectionClient(AltingChannelInput input, ChannelOutput toLink, Link link, ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static NetAltingConnectionClientcreate(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX)voiddestroy()Destroys the Networked construct(package private) ConnectionDatagetConnectionData()(package private) NetConnectionLocationgetLocalLocation()NetLocationgetLocation()Gets the networked location of the Networked constructbooleanisOpen()Returns whether the server has kept its end of the Connection open.java.lang.Objectreply()Receives some data back from the server afterrequest(Object)has been called.voidrequest(java.lang.Object obj)This method is used to send data to aConnectionServerin a client/server conversation.-
Methods inherited from class org.jcsp.lang.AltingConnectionClient
getAltingChannel, pending, setAltingChannel
-
-
-
-
Field Detail
-
in
private final AltingChannelInput in
-
toLinkTX
private final ChannelOutput toLinkTX
-
linkConnectedTo
private final Link linkConnectedTo
-
serverLocation
private final NetConnectionLocation serverLocation
-
localLocation
private final NetConnectionLocation localLocation
-
localConnection
private final ConnectionData localConnection
-
isLocal
private final boolean isLocal
-
outputFilter
private final NetworkMessageFilter.FilterTx outputFilter
-
inputFilter
private final NetworkMessageFilter.FilterRx inputFilter
-
data
private final ConnectionData data
-
-
Constructor Detail
-
NetAltingConnectionClient
private NetAltingConnectionClient(AltingChannelInput input, ChannelOutput toLink, Link link, ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX)
-
-
Method Detail
-
create
static NetAltingConnectionClient create(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) throws JCSPNetworkException
- Throws:
JCSPNetworkException
-
isOpen
public boolean isOpen() throws java.lang.IllegalStateException, JCSPNetworkExceptionDescription copied from interface:ConnectionClientReturns whether the server has kept its end of the Connection open. This should only be called after a call to
reply()and before any other Connection method is called.- Specified by:
isOpenin interfaceConnectionClient- Returns:
trueiff the server has kept the connection open.- Throws:
java.lang.IllegalStateExceptionJCSPNetworkException
-
reply
public java.lang.Object reply() throws java.lang.IllegalStateException, JCSPNetworkExceptionDescription copied from interface:ConnectionClientReceives some data back from the server after
request(Object)has been called.After calling this method,
isOpen()may be called to establish whether the server dropped the connection after replying.Implementations may make this operation ALTable.
- Specified by:
replyin interfaceConnectionClient- Returns:
- the
Objectsent from the server. - Throws:
java.lang.IllegalStateException- if the method is called when it is not meant to be.JCSPNetworkException
-
request
public void request(java.lang.Object obj) throws java.lang.IllegalStateException, JCSPNetworkExceptionDescription copied from interface:ConnectionClientThis method is used to send data to a
ConnectionServerin a client/server conversation. If a connection has not yet been established, then this method will open the connection as necessary.Once this method has returned, the client may do some computation but must then guarantee to call
reply(). This will obtain a server's response to the request. In between calling this method andreply(), doing pure computation is safe. Performing synchronization with other process is potentially hazardous.Once a server replies, if the connection has been kept open, then this method should be called again to make a further request.
Programs using
Connections need to adopt a protocol so that the server knows when a conversation with a client has finished and will then drop the connection.- Specified by:
requestin interfaceConnectionClient- Parameters:
obj- theObjectto send to the server.- Throws:
java.lang.IllegalStateException- if the method is called when it is not meant to be.JCSPNetworkException
-
destroy
public void destroy()
Description copied from interface:NetworkedDestroys the Networked construct
-
getLocation
public NetLocation getLocation()
Description copied from interface:NetworkedGets the networked location of the Networked construct- Specified by:
getLocationin interfaceNetworked- Returns:
- The location of the construct
-
getLocalLocation
NetConnectionLocation getLocalLocation()
-
getConnectionData
final ConnectionData getConnectionData()
-
-