Package org.eclipse.net4j.channel
Interface IChannel
- 
- All Superinterfaces:
- org.eclipse.net4j.util.collection.Closeable,- IBufferHandler,- ILocationAware,- org.eclipse.net4j.util.event.INotifier,- org.eclipse.net4j.util.security.IUserAware
 - All Known Subinterfaces:
- IJVMChannel,- InternalChannel
 - All Known Implementing Classes:
- 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 ofbuffers. 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 achannel multiplexer.An example for opening a channel on an IConnectorand sending anIBuffer:// 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 IBuffers from channels on anIConnector:// 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); } });- Author:
- 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.
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.eclipse.net4j.ILocationAwareILocationAware.Location
 
- 
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description shortgetID()Returns the ID of this channel.IChannelMultiplexergetMultiplexer()Returns the multiplexer this channel is associated with.longgetReceivedBuffers()Returns the number ofbuffersthat are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.longgetReceivedBytes()Returns the number of bytes that are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.IBufferHandlergetReceiveHandler()Returns theIBufferHandlerthat handles buffers received from the peer channel.longgetSentBuffers()Returns the number ofbuffersthat are sent to themultiplexerof this channel.longgetSentBytes()Returns the number of bytes that are sent to themultiplexerof this channel.voidsendBuffer(IBuffer buffer)Asynchronously sends the given buffer to the receive handler of the peer channel.voidsetReceiveHandler(IBufferHandler receiveHandler)Sets theIBufferHandlerto handle buffers received from the peer channel.- 
Methods inherited from interface org.eclipse.net4j.buffer.IBufferHandlerhandleBuffer
 - 
Methods inherited from interface org.eclipse.net4j.ILocationAwaregetLocation, isClient, isServer
 
- 
 
- 
- 
- 
Method Detail- 
getIDshort getID() Returns the ID of this channel. The ID is unique at any time among all channels of the associatedmultiplexer.- Since:
- 2.0
 
 - 
getMultiplexerIChannelMultiplexer 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.- Since:
- 2.0
 
 - 
sendBuffervoid sendBuffer(IBuffer buffer) Asynchronously sends the given buffer to the receive handler of the peer channel.
 - 
getReceiveHandlerIBufferHandler getReceiveHandler() Returns theIBufferHandlerthat handles buffers received from the peer channel.
 - 
setReceiveHandlervoid setReceiveHandler(IBufferHandler receiveHandler) Sets theIBufferHandlerto handle buffers received from the peer channel.
 - 
getSentBufferslong getSentBuffers() Returns the number ofbuffersthat are sent to themultiplexerof this channel.- Since:
- 4.10
 
 - 
getSentByteslong getSentBytes() Returns the number of bytes that are sent to themultiplexerof this channel.- Since:
- 4.13
 
 - 
getReceivedBufferslong getReceivedBuffers() Returns the number ofbuffersthat are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.- Since:
- 4.10
 
 - 
getReceivedByteslong getReceivedBytes() Returns the number of bytes that are received from themultiplexerof this channel and are passed on to thereceive handlerof this channel.- Since:
- 4.13
 
 
- 
 
-