Class UdpKernel

java.lang.Object
com.jme3.network.kernel.AbstractKernel
com.jme3.network.kernel.udp.UdpKernel
All Implemented Interfaces:
Kernel

public class UdpKernel extends AbstractKernel
A Kernel implementation using UDP packets.
Author:
Paul Speed
  • Constructor Details

    • UdpKernel

      public UdpKernel(InetAddress host, int port)
      Creates a UDP kernel for the specified host and port.
      Parameters:
      host - the local bind address
      port - the local bind port
    • UdpKernel

      public UdpKernel(int port) throws IOException
      Creates a UDP kernel bound to the specified port on the wildcard address.
      Parameters:
      port - the local bind port
      Throws:
      IOException - if the address cannot be prepared
    • UdpKernel

      public UdpKernel(InetSocketAddress address)
      Creates a UDP kernel for the specified socket address.
      Parameters:
      address - the local socket address
  • Method Details

    • createHostThread

      protected UdpKernel.HostThread createHostThread()
      Creates the host thread implementation used by this kernel.
      Returns:
      the host thread
    • initialize

      public void initialize()
      Description copied from interface: Kernel
      Initializes the kernel and starts any internal processing.
    • terminate

      public void terminate() throws InterruptedException
      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 - if the calling thread is interrupted while waiting
    • broadcast

      public void broadcast(Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy)
      Dispatches the data to all endpoints managed by the kernel. 'routing' is currently ignored.
      Parameters:
      filter - the endpoint filter used to select recipients
      data - the payload to send
      reliable - true to use reliable transport semantics
      copy - true to copy the buffer before dispatching it
    • getEndpoint

      protected Endpoint getEndpoint(SocketAddress address, boolean create)
      Returns the endpoint for the specified socket address, optionally creating it.
      Parameters:
      address - the remote socket address
      create - true to create the endpoint if missing
      Returns:
      the existing or newly created endpoint
    • closeEndpoint

      protected void closeEndpoint(UdpEndpoint p) throws IOException
      Called by the endpoints when they need to be closed.
      Parameters:
      p - the endpoint to close
      Throws:
      IOException - if cleanup fails
    • newData

      protected void newData(DatagramPacket packet)
      Queues newly received datagram data as an envelope.
      Parameters:
      packet - the received packet
    • enqueueWrite

      protected void enqueueWrite(Endpoint endpoint, DatagramPacket packet)
      Queues a datagram for asynchronous sending.
      Parameters:
      endpoint - the source endpoint
      packet - the packet to send