com.jme3.network.kernel.tcp
Class NioEndpoint

java.lang.Object
  extended by com.jme3.network.kernel.tcp.NioEndpoint
All Implemented Interfaces:
Endpoint

public class NioEndpoint
extends java.lang.Object
implements Endpoint

Endpoint implementation that encapsulates the channel IO based connection information and keeps track of the outbound data queue for the channel.


Field Summary
protected static java.nio.ByteBuffer CLOSE_MARKER
           
 
Constructor Summary
NioEndpoint(SelectorKernel kernel, long id, java.nio.channels.SocketChannel socket)
           
 
Method Summary
 void close()
          Closes this endpoint without flushing any of its currently enqueued outbound data.
 void close(boolean flushData)
          Closes this endpoint, optionally flushing any queued data before closing.
 java.lang.String getAddress()
          Returns the transport specific remote address of this endpoint as a string.
 long getId()
          Returns an ID that is unique for this endpoint within its Kernel instance.
 Kernel getKernel()
          Returns the kernel to which this endpoint belongs.
protected  boolean hasPending()
           
 boolean isConnected()
          Returns true if this endpoint is currently connected.
protected  java.nio.ByteBuffer peekPending()
          Called by the SelectorKernel to get the current top buffer for writing.
protected  java.nio.ByteBuffer removePending()
          Called by the SelectorKernel when the top buffer has been exhausted.
 void send(java.nio.ByteBuffer data)
          Sends data to the other end of the connection represented by this endpoint.
protected  void send(java.nio.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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLOSE_MARKER

protected static final java.nio.ByteBuffer CLOSE_MARKER
Constructor Detail

NioEndpoint

public NioEndpoint(SelectorKernel kernel,
                   long id,
                   java.nio.channels.SocketChannel socket)
Method Detail

getKernel

public Kernel getKernel()
Description copied from interface: Endpoint
Returns the kernel to which this endpoint belongs.

Specified by:
getKernel in interface Endpoint

close

public void close()
Description copied from interface: Endpoint
Closes this endpoint without flushing any of its currently enqueued outbound data.

Specified by:
close in interface Endpoint

close

public void close(boolean flushData)
Description copied from interface: Endpoint
Closes this endpoint, optionally flushing any queued data before closing. As soon as this method is called, ne send() calls will fail with an exception... even while close() is still flushing the earlier queued messages.

Specified by:
close in interface Endpoint

getId

public long getId()
Description copied from interface: Endpoint
Returns an ID that is unique for this endpoint within its Kernel instance.

Specified by:
getId in interface Endpoint

getAddress

public java.lang.String getAddress()
Description copied from interface: Endpoint
Returns 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:
getAddress in interface Endpoint

isConnected

public boolean isConnected()
Description copied from interface: Endpoint
Returns true if this endpoint is currently connected.

Specified by:
isConnected in interface Endpoint

send

protected void send(java.nio.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.


peekPending

protected java.nio.ByteBuffer peekPending()
Called by the SelectorKernel to get the current top buffer for writing.


removePending

protected java.nio.ByteBuffer removePending()
Called by the SelectorKernel when the top buffer has been exhausted.


hasPending

protected boolean hasPending()

send

public void send(java.nio.ByteBuffer data)
Description copied from interface: Endpoint
Sends data to the other end of the connection represented by this endpoint.

Specified by:
send in interface Endpoint

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object