Class UdpEndpoint

java.lang.Object
com.jme3.network.kernel.udp.UdpEndpoint
All Implemented Interfaces:
Endpoint

public class UdpEndpoint extends Object implements Endpoint
Endpoint implementation that encapsulates the UDP connection information for return messaging, identification of envelope sources, etc.
Author:
Paul Speed
  • Constructor Details

    • UdpEndpoint

      public UdpEndpoint(UdpKernel kernel, long id, SocketAddress address, DatagramSocket socket)
      Creates a UDP endpoint.
      Parameters:
      kernel - the owning kernel
      id - the endpoint id
      address - the remote socket address
      socket - the datagram socket used for replies
  • Method Details

    • getKernel

      public Kernel getKernel()
      Description copied from interface: Endpoint
      Returns the kernel to which this endpoint belongs.
      Specified by:
      getKernel in interface Endpoint
      Returns:
      the owning kernel
    • getRemoteAddress

      protected SocketAddress getRemoteAddress()
      Returns the remote socket address for this endpoint.
      Returns:
      the remote socket address
    • 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 flush)
      Description copied from interface: Endpoint
      Closes 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.
      Specified by:
      close in interface Endpoint
      Parameters:
      flush - true to flush queued data before closing
    • 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
      Returns:
      the endpoint id
    • getAddress

      public 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
      Returns:
      the remote address string
    • isConnected

      public boolean isConnected()
      Description copied from interface: Endpoint
      Returns true if this endpoint is currently connected.
      Specified by:
      isConnected in interface Endpoint
      Returns:
      true if the endpoint is connected
    • send

      public void send(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
      Parameters:
      data - the bytes to send
    • toString

      public String toString()
      Overrides:
      toString in class Object