public class ChannelTable extends java.lang.Object implements IDataChannelCreator
Modifier and Type | Field and Description |
---|---|
static int |
CONTROL_CHANNEL_ID_DUMMY |
static int |
CONTROL_CHANNEL_ID_PAY |
static int |
CONTROL_CHANNEL_ID_REPLAY |
static int |
CONTROL_CHANNEL_ID_TEST |
Constructor and Description |
---|
ChannelTable(IDataChannelFactory a_dataChannelFactory,
java.security.SecureRandom a_channelIdGenerator,
int maxDataChannels)
Creates a channel table to hold data and control channels.
|
Modifier and Type | Method and Description |
---|---|
void |
closeChannelTable()
This method notifies all channels in the table, that it will be closed and
clears itself afterwards.
|
AbstractDataChannel |
createDataChannel(AbstractDataChain a_parentDataChain)
This method creates a new channel using the channel factory specified at
construction time and inserts it into the table with a random, available ID.
|
AbstractChannel |
getChannel(int a_channelId)
Returns the channel for a given ID.
|
boolean |
isControlChannelId(int a_channelId)
Checks if the given integer number is reserved for control channel IDs.
|
boolean |
isSendingControlMessage()
Returns true if any of the control channels in this table is sending
control messages at that moment.
|
void |
registerControlChannel(int a_channelId,
AbstractControlChannel a_controlChannel)
Registers a given control channel under the given ID in the channel table
and the control channel table.
|
void |
removeChannel(int a_channelId)
Remove a channel with the given ID from the channel table and notify
threads of the new available channel spot, if the removed channel was a
data channel.
|
public static final int CONTROL_CHANNEL_ID_PAY
public static final int CONTROL_CHANNEL_ID_REPLAY
public static final int CONTROL_CHANNEL_ID_DUMMY
public static final int CONTROL_CHANNEL_ID_TEST
public ChannelTable(IDataChannelFactory a_dataChannelFactory, java.security.SecureRandom a_channelIdGenerator, int maxDataChannels)
a_dataChannelFactory
- a factory used for creating data channelsa_channelIdGenerator
- a secure random number generator used to
generate the channel IDsmaxDataChannels
- max number of data channels, default (50) if -1public AbstractChannel getChannel(int a_channelId)
a_channelId
- public void removeChannel(int a_channelId)
a_channelId
- public boolean isSendingControlMessage()
public void registerControlChannel(int a_channelId, AbstractControlChannel a_controlChannel)
If the table is closed, the given channel will be closed, without adding it.
Control Channels register themselves on Construction with a channel ID previously agreed upon with the Channel Table.
a_channelId
- a_controlChannel
- public boolean isControlChannelId(int a_channelId)
a_channelId
- Integer to be tested.public AbstractDataChannel createDataChannel(AbstractDataChain a_parentDataChain)
This method blocks, if there are no available data channel slots left at that moment and the table is not closed.
If the table is closed a dummy channel is created and closed immediately by calling multiplexerClosed().
createDataChannel
in interface IDataChannelCreator
public void closeChannelTable()
Copyright © 2023. All rights reserved.