Class NetAltingConnectionServer
- java.lang.Object
-
- org.jcsp.lang.Guard
-
- org.jcsp.lang.AltingConnectionServer
-
- org.jcsp.net2.NetAltingConnectionServer
-
- All Implemented Interfaces:
ConnectionServer
,NetConnectionServer
,Networked
public final class NetAltingConnectionServer extends AltingConnectionServer implements NetConnectionServer
-
-
Field Summary
Fields Modifier and Type Field Description private ConnectionData
data
private NetworkMessageFilter.FilterRx
inputFilter
private NetworkMessage
lastRead
private Link
linkConnectedTo
private NetConnectionLocation
location
private AltingChannelInput
openIn
private NetworkMessageFilter.FilterTx
outputFilter
private AltingChannelInput
requestIn
-
Fields inherited from interface org.jcsp.lang.ConnectionServer
FACTORY
-
-
Constructor Summary
Constructors Modifier Constructor Description private
NetAltingConnectionServer(AltingChannelInput openChan, AltingChannelInput requestChan, ConnectionData connData, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static NetAltingConnectionServer
create(int index, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX)
(package private) static NetAltingConnectionServer
create(NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX)
void
destroy()
Destroys the Networked constructNetLocation
getLocation()
Gets the networked location of the Networked constructvoid
reply(java.lang.Object data)
Sends some data back to the client after a request has been received but keeps the connection open.void
reply(java.lang.Object data, boolean close)
Sends some data back to the client after a request has been received.void
replyAndClose(java.lang.Object data)
Sends some data back to the client and closes the connection.java.lang.Object
request()
Receives a request from a client.-
Methods inherited from class org.jcsp.lang.AltingConnectionServer
getAltingChannel, pending, setAltingChannel
-
-
-
-
Field Detail
-
requestIn
private final AltingChannelInput requestIn
-
openIn
private final AltingChannelInput openIn
-
location
private final NetConnectionLocation location
-
inputFilter
private final NetworkMessageFilter.FilterRx inputFilter
-
outputFilter
private final NetworkMessageFilter.FilterTx outputFilter
-
data
private final ConnectionData data
-
lastRead
private final NetworkMessage lastRead
-
linkConnectedTo
private final Link linkConnectedTo
-
-
Constructor Detail
-
NetAltingConnectionServer
private NetAltingConnectionServer(AltingChannelInput openChan, AltingChannelInput requestChan, ConnectionData connData, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) throws JCSPNetworkException
- Throws:
JCSPNetworkException
-
-
Method Detail
-
create
static NetAltingConnectionServer create(int index, NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
create
static NetAltingConnectionServer create(NetworkMessageFilter.FilterRx filterRX, NetworkMessageFilter.FilterTx filterTX)
-
destroy
public void destroy()
Description copied from interface:Networked
Destroys the Networked construct
-
getLocation
public NetLocation 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
-
reply
public void reply(java.lang.Object data, boolean close) throws java.lang.IllegalStateException
Description copied from interface:ConnectionServer
Sends some data back to the client after a request has been received. The
boolean
close parameter indicates whether the connection should be closed after this reply has been sent.This method should not block.
- Specified by:
reply
in interfaceConnectionServer
- Parameters:
data
- the data to send back to client.close
-boolean
that should betrue
iff the connection should be dropped after the reply has been sent.- Throws:
java.lang.IllegalStateException
-
reply
public void reply(java.lang.Object data) throws java.lang.IllegalStateException
Description copied from interface:ConnectionServer
Sends some data back to the client after a request has been received but keeps the connection open. After calling this method, the server should call
recieve()
to receive a further request.A call to this method is equivalent to a call to
reply(Object, boolean)
with the boolean set tofalse
.- Specified by:
reply
in interfaceConnectionServer
- Parameters:
data
- the data to send to the client.- Throws:
java.lang.IllegalStateException
-
replyAndClose
public void replyAndClose(java.lang.Object data) throws java.lang.IllegalStateException
Description copied from interface:ConnectionServer
Sends some data back to the client and closes the connection.
A call to this method is equivalent to a call to
reply(Object, boolean)
with the boolean set totrue
.- Specified by:
replyAndClose
in interfaceConnectionServer
- Parameters:
data
- the data to send back to client.- Throws:
java.lang.IllegalStateException
-
request
public java.lang.Object request() throws java.lang.IllegalStateException
Description copied from interface:ConnectionServer
Receives a request from a client. This will block until the client calls its
request(Object)
method. Implementations may make this ALTable.After this method has returned, the server should call one of the reply methods. Performing any external process synchronization between these method calls could be potentially hazardous and could lead to deadlock.
- Specified by:
request
in interfaceConnectionServer
- Returns:
- the
Object
sent by the client. - Throws:
java.lang.IllegalStateException
-
-