Package com.jme3.network.kernel.tcp
Class SelectorKernel
java.lang.Object
com.jme3.network.kernel.AbstractKernel
com.jme3.network.kernel.tcp.SelectorKernel
- All Implemented Interfaces:
Kernel
A Kernel implementation based on NIO selectors.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
This class is purposely tucked neatly away because messing with the selector from other threads for any reason is very bad. -
Field Summary
Fields inherited from interface com.jme3.network.kernel.Kernel
EVENTS_PENDING
-
Constructor Summary
ConstructorDescriptionSelectorKernel
(int port) SelectorKernel
(InetAddress host, int port) SelectorKernel
(InetSocketAddress address) -
Method Summary
Modifier and TypeMethodDescriptionprotected NioEndpoint
void
broadcast
(Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy) Dispatches the data to all endpoints managed by the kernel that match the specified endpoint filter.protected void
Called by the endpoints when they need to be closed.protected SelectorKernel.SelectorThread
void
Initializes the kernel and starts any internal processing.protected void
newData
(NioEndpoint p, SocketChannel c, ByteBuffer shared, int size) protected void
void
Gracefully terminates the kernel and stops any internal daemon processing.protected void
Used internally by the endpoints to wake up the selector when they have data to send.Methods inherited from class com.jme3.network.kernel.AbstractKernel
addEnvelope, addEvent, hasEnvelopes, nextEndpointId, nextEvent, read, reportError, wakeupReader
-
Constructor Details
-
SelectorKernel
-
SelectorKernel
- Throws:
IOException
-
SelectorKernel
-
-
Method Details
-
createSelectorThread
-
initialize
public void initialize()Description copied from interface:Kernel
Initializes the kernel and starts any internal processing. -
terminate
Description copied from interface:Kernel
Gracefully terminates the kernel and stops any internal daemon processing. This method will not return until all internal threads have been shut down.- Throws:
InterruptedException
-
broadcast
public void broadcast(Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy) Description copied from interface:Kernel
Dispatches the data to all endpoints managed by the kernel that match the specified endpoint filter. If 'copy' is true then the implementation will copy the byte buffer before delivering it to endpoints. This allows the caller to reuse the data buffer. Though it is important that the buffer not be changed by another thread while this call is running. Only the bytes from data.position() to data.remaining() are sent. -
addEndpoint
-
removeEndpoint
-
closeEndpoint
Called by the endpoints when they need to be closed.- Throws:
IOException
-
wakeupSelector
protected void wakeupSelector()Used internally by the endpoints to wake up the selector when they have data to send. -
newData
-