Class NioEndpoint
java.lang.Object
com.jme3.network.kernel.tcp.NioEndpoint
- All Implemented Interfaces:
Endpoint
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ByteBufferMarker queued to request endpoint closure after pending writes flush. -
Constructor Summary
ConstructorsConstructorDescriptionNioEndpoint(SelectorKernel kernel, long id, SocketChannel socket) Creates an endpoint backed by a socket channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this endpoint without flushing any of its currently enqueued outbound data.voidclose(boolean flushData) Closes this endpoint, optionally flushing any queued data before closing.Returns the transport specific remote address of this endpoint as a string.longgetId()Returns an ID that is unique for this endpoint within its Kernel instance.Returns the kernel to which this endpoint belongs.protected booleanReturns true if outbound data is queued for this endpoint.booleanReturns true if this endpoint is currently connected.protected ByteBufferCalled by the SelectorKernel to get the current top buffer for writing.protected ByteBufferCalled by the SelectorKernel when the top buffer has been exhausted.voidsend(ByteBuffer data) Sends data to the other end of the connection represented by this endpoint.protected voidsend(ByteBuffer data, boolean copy, boolean wakeup) The wakeup option is used internally when the kernel is broadcasting out to a bunch of endpoints and doesn't want to necessarily wakeup right away.toString()
-
Field Details
-
CLOSE_MARKER
Marker queued to request endpoint closure after pending writes flush.
-
-
Constructor Details
-
NioEndpoint
Creates an endpoint backed by a socket channel.- Parameters:
kernel- the owning selector kernelid- the endpoint idsocket- the socket channel
-
-
Method Details
-
getKernel
-
close
-
close
public void close(boolean flushData) Description copied from interface:EndpointCloses this endpoint, optionally flushing any queued data before closing. As soon as this method is called, new send() calls will fail with an exception... even while close() is still flushing the earlier queued messages. -
getId
-
getAddress
Description copied from interface:EndpointReturns the transport specific remote address of this endpoint as a string. This may or may not be unique per endpoint depending on the type of transport.- Specified by:
getAddressin interfaceEndpoint- Returns:
- the remote address string
-
isConnected
public boolean isConnected()Description copied from interface:EndpointReturns true if this endpoint is currently connected.- Specified by:
isConnectedin interfaceEndpoint- Returns:
- true if the endpoint is connected
-
send
The wakeup option is used internally when the kernel is broadcasting out to a bunch of endpoints and doesn't want to necessarily wakeup right away.- Parameters:
data- the bytes to queuecopy- true to copy the provided bufferwakeup- true to wake the selector after enqueueing
-
peekPending
Called by the SelectorKernel to get the current top buffer for writing.- Returns:
- the current pending buffer, or null if none are queued
-
removePending
Called by the SelectorKernel when the top buffer has been exhausted.- Returns:
- the removed pending buffer, or null if none are queued
-
hasPending
protected boolean hasPending()Returns true if outbound data is queued for this endpoint.- Returns:
- true if pending outbound data exists
-
send
Description copied from interface:EndpointSends data to the other end of the connection represented by this endpoint. -
toString
-