public interface MultipartyCommunicationSetup
There are several ways to communicate between parties - using sockets, queues, etc. Each concrete way should implements this interface and the functions in it.
This interface should be used in the general case of communication between multiple parties. In case of two parties there is a simpler interface
that can be used, called
The Communications Layer package is a tool used by a client that is interested in setting up connections between itself and other party. As such, this layer does not initiate any independent tasks, but the opposite. Given two parties, it attempts to set connections to them according to parameters given by the calling application. If succeeds, it returns these connections so that the calling client can send and receive data over them.
Note that multiple connections can be created between each pair of parties; the user can ask to set any number of connections between him and every other party. An application written for running a multiparty protocol can be the client of the Communications Layer. An example of a possible usage follows:
|Modifier and Type||Method and Description|
There are several implementations that should close the communication object.
Enables to use Nagle algrithm in the communication.
An application that wants to use the communication layer will call this function in order to prepare for communication after providing the required parameters.
java.util.Map<PartyData,java.util.Map<java.lang.String,Channel>> prepareForCommunication(java.util.Map<PartyData,java.lang.Object> connectionsPerParty, long timeOut) throws java.util.concurrent.TimeoutException
The constructor of the concrete classes should receive the data of the parties participate in the communication. After that, this function initiates the creation of the final actual connections between the parties.
This function gets a map that contains number of connection that should be established between the current party (application) and any other party in the protocol. The key for the map is the PartyData object contains the data of the other party and the value in the map can be two different things: 1. Integer - the number of connections that should be established between the current party and the party in the key. 2. String - the names of the connections that should be established between the current party and the party in the key. Each connection has a unique name, that we call ID. This name used to distinguish between the created connections in order to make it easier and more convenient to understand what is the usage of each connection.
If this function succeeds, the application may use the send and receive functions of the created channels to pass messages.
In this function, Nagle's algorithm is disabled; for cryptographic protocols this is typically much better. In order to use the Nagle algorithm, call the enableNagle() function.
connectionsPerParty- indicates the amount of connections or the names of connections that should be created between the current application and any other party in the protocol
timeOut- the maximum amount of time we allow for the connection stage.
java.util.concurrent.TimeoutException- in case a timeout has occurred before all channels have been connected.
By default Nagle algorithm is disabled since it is much better for cryptographic algorithms.