Package org.eclipse.net4j.channel
Schnittstelle IChannel
- Alle Superschnittstellen:
org.eclipse.net4j.util.collection.Closeable
,IBufferHandler
,ILocationAware
,org.eclipse.net4j.util.event.INotifier
,org.eclipse.net4j.util.security.IUserAware
- Alle bekannten Unterschnittstellen:
IJVMChannel
,InternalChannel
- Alle bekannten Implementierungsklassen:
Channel
public interface IChannel
extends ILocationAware, org.eclipse.net4j.util.security.IUserAware, IBufferHandler, org.eclipse.net4j.util.event.INotifier, org.eclipse.net4j.util.collection.Closeable
A bidirectional communications channel for the asynchronous exchange of
buffers
. A channel is
lightweight and virtual in the sense that it does not necessarily represent a single physical connection like a TCP
socket connection. The underlying physical connection is represented by a channel
multiplexer
.
An example for opening a channel on an IConnector
and sending an IBuffer
:
// Open a channel IChannel channel = connector.openChannel(); short channelID = channel.getIndex(); // Fill a buffer Buffer buffer = bufferProvider.getBuffer(); ByteBuffer byteBuffer = buffer.startPutting(channelID); byteBuffer.putDouble(15.47); // Let the channel send the buffer without blocking channel.sendBuffer(buffer);
An example for receiving IBuffer
s from channels on an IConnector
:
// Create a receive handler final IBufferHandler receiveHandler = new IBufferHandler() { public void handleBuffer(IBuffer buffer) { ByteBuffer byteBuffer = buffer.getByteBuffer(); IOUtil.OUT().println("Received " + byteBuffer.getDouble()); buffer.release(); } }; // Set the receive handler to all new channels connector.addListener(new ContainerEventAdapter() { protected void onAdded(IContainer container, Object element) { IChannel channel = (IChannel)element; channel.setReceiveHandler(receiveHandler); } });
- Autor:
- Eike Stepper
- No Implement
- This interface is not intended to be implemented by clients.
- No Extend
- This interface is not intended to be extended by clients.
-
Verschachtelte Klassen - Übersicht
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.net4j.ILocationAware
ILocationAware.Location
Von Schnittstelle geerbte verschachtelte Klassen/Schnittstellen org.eclipse.net4j.util.event.INotifier
org.eclipse.net4j.util.event.INotifier.INotifier2
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungshort
getID()
Returns the ID of this channel.Returns the multiplexer this channel is associated with.long
Returns the number ofbuffers
that are received from themultiplexer
of this channel and are passed on to thereceive handler
of this channel.long
Returns the number of bytes that are received from themultiplexer
of this channel and are passed on to thereceive handler
of this channel.Returns theIBufferHandler
that handles buffers received from the peer channel.long
Returns the number ofbuffers
that are sent to themultiplexer
of this channel.long
Returns the number of bytes that are sent to themultiplexer
of this channel.void
sendBuffer
(IBuffer buffer) Asynchronously sends the given buffer to the receive handler of the peer channel.void
setReceiveHandler
(IBufferHandler receiveHandler) Sets theIBufferHandler
to handle buffers received from the peer channel.Von Schnittstelle geerbte Methoden org.eclipse.net4j.util.collection.Closeable
close, isClosed
Von Schnittstelle geerbte Methoden org.eclipse.net4j.buffer.IBufferHandler
handleBuffer
Von Schnittstelle geerbte Methoden org.eclipse.net4j.ILocationAware
getLocation, isClient, isServer
Von Schnittstelle geerbte Methoden org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListener
Von Schnittstelle geerbte Methoden org.eclipse.net4j.util.security.IUserAware
getUserID
-
Methodendetails
-
getID
short getID()Returns the ID of this channel. The ID is unique at any time among all channels of the associatedmultiplexer
.- Seit:
- 2.0
-
getMultiplexer
IChannelMultiplexer getMultiplexer()Returns the multiplexer this channel is associated with. This channel multiplexer can be used, for example, to open additional channels that will be multiplexed through the same transport medium.- Seit:
- 2.0
-
sendBuffer
Asynchronously sends the given buffer to the receive handler of the peer channel. -
getReceiveHandler
IBufferHandler getReceiveHandler()Returns theIBufferHandler
that handles buffers received from the peer channel. -
setReceiveHandler
Sets theIBufferHandler
to handle buffers received from the peer channel. -
getSentBuffers
long getSentBuffers()Returns the number ofbuffers
that are sent to themultiplexer
of this channel.- Seit:
- 4.10
-
getSentBytes
long getSentBytes()Returns the number of bytes that are sent to themultiplexer
of this channel.- Seit:
- 4.13
-
getReceivedBuffers
long getReceivedBuffers()Returns the number ofbuffers
that are received from themultiplexer
of this channel and are passed on to thereceive handler
of this channel.- Seit:
- 4.10
-
getReceivedBytes
long getReceivedBytes()Returns the number of bytes that are received from themultiplexer
of this channel and are passed on to thereceive handler
of this channel.- Seit:
- 4.13
-