Class NetAltingConnectionClient
- All Implemented Interfaces:
ConnectionClient
,NetConnectionClient
,Networked
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConnectionData
private final AltingChannelInput
private final NetworkMessageFilter.FilterRx
private final boolean
private final Link
private final ConnectionData
private final NetConnectionLocation
private final NetworkMessageFilter.FilterTx
private final NetConnectionLocation
private final ChannelOutput
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
NetAltingConnectionClient
(AltingChannelInput input, ChannelOutput toLink, Link link, ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) -
Method Summary
Modifier and TypeMethodDescription(package private) static NetAltingConnectionClient
create
(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) void
destroy()
Destroys the Networked construct(package private) final ConnectionData
(package private) NetConnectionLocation
Gets the networked location of the Networked constructboolean
isOpen()
Returns whether the server has kept its end of the Connection open.reply()
Receives some data back from the server afterrequest(Object)
has been called.void
This method is used to send data to aConnectionServer
in a client/server conversation.Methods inherited from class org.jcsp.lang.AltingConnectionClient
getAltingChannel, pending, setAltingChannel
-
Field Details
-
in
-
toLinkTX
-
linkConnectedTo
-
serverLocation
-
localLocation
-
localConnection
-
isLocal
private final boolean isLocal -
outputFilter
-
inputFilter
-
data
-
-
Constructor Details
-
NetAltingConnectionClient
private NetAltingConnectionClient(AltingChannelInput input, ChannelOutput toLink, Link link, ConnectionData connData, NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX)
-
-
Method Details
-
create
static NetAltingConnectionClient create(NetConnectionLocation loc, NetworkMessageFilter.FilterTx filterTX, NetworkMessageFilter.FilterRx filterRX) throws JCSPNetworkException - Throws:
JCSPNetworkException
-
isOpen
Description copied from interface:ConnectionClient
Returns 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:
isOpen
in interfaceConnectionClient
- Returns:
true
iff the server has kept the connection open.- Throws:
IllegalStateException
JCSPNetworkException
-
reply
Description copied from interface:ConnectionClient
Receives 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:
reply
in interfaceConnectionClient
- Returns:
- the
Object
sent from the server. - Throws:
IllegalStateException
- if the method is called when it is not meant to be.JCSPNetworkException
-
request
Description copied from interface:ConnectionClient
This method is used to send data to a
ConnectionServer
in 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
Connection
s 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:
request
in interfaceConnectionClient
- Parameters:
obj
- theObject
to send to the server.- Throws:
IllegalStateException
- if the method is called when it is not meant to be.JCSPNetworkException
-
destroy
public void destroy()Description copied from interface:Networked
Destroys the Networked construct -
getLocation
Description copied from interface:Networked
Gets the networked location of the Networked construct- Specified by:
getLocation
in interfaceNetworked
- Returns:
- The location of the construct
-
getLocalLocation
NetConnectionLocation getLocalLocation() -
getConnectionData
-