Class XTablesServer

java.lang.Object
org.kobe.xbot.JServer.XTablesServer

public class XTablesServer extends Object
XTablesServer - A server class for managing JeroMQ-based messaging and mDNS service registration.

This class initializes and manages the server components, including JeroMQ sockets for handling PUB, PULL, and REQ/REP messaging patterns. It also supports mDNS registration for service discovery.

Author: Kobe Lei Version: 1.0 Package: XTABLES

This is part of the XTABLES project and provides core server functionality in a multithreaded environment.

  • Field Details

  • Method Details

    • initialize

      public static XTablesServer initialize(String version, int pullSocketPort, int replySocketPort, int publishSocketPort, boolean additionalFeatures)
      Initializes the XTablesServer instance and starts the main server thread. Ensures the server is properly cleaned up during JVM shutdown.
      Parameters:
      pullSocketPort - Port for the PULL socket
      replySocketPort - Port for the REP socket
      publishSocketPort - Port for the PUB socket
      Returns:
      The initialized server instance
    • getInstance

      public static XTablesServer getInstance()
      Retrieves the current instance of the XTablesServer.
      Returns:
      The current server instance, or null if not initialized
    • restart

      public void restart()
      Restarts the server by performing a clean shutdown followed by a restart. Updates the server status appropriately and ensures proper resource management.
    • shutdown

      public void shutdown()
      Shuts down the server and releases all associated resources, including JeroMQ context, mDNS service, and handler threads.
    • getRate

      public XTablesMessageRate getRate()
    • getTable

      public XTablesData getTable()
      Returns the current data table associated with this instance.
      Returns:
      an instance of XTablesData representing the current table data.
    • getClientRegistry

      public ClientRegistry getClientRegistry()
      Returns the ClientRegistry instance associated with the XTables server.

      This method provides access to the ClientRegistry, which manages the list of connected clients and periodically updates the server with new session IDs and client information. The ClientRegistry operates as a background thread that handles client management tasks.

      Returns:
      the ClientRegistry instance managing client connections and session updates
    • getClientRegistrySessionId

      public com.google.protobuf.ByteString getClientRegistrySessionId()
    • getClientRegistrySession

      public AtomicReference<com.google.protobuf.ByteString> getClientRegistrySession()
    • getIterationSpeed

      public int getIterationSpeed()
      Retrieves the iteration speed.

      This method returns the number of iterations per second that the server can process, representing its current processing capability.

      Returns:
      the iteration speed as an integer
    • getVersion

      public String getVersion()
      Retrieves the version of the server.

      This method provides the version string for the current instance, which can be useful for diagnostics or display purposes.

      Returns:
      the version as a string
    • getStatus

      public XTableStatus getStatus()
      Retrieves the current status of the server.

      This method accesses the current status stored in an atomic reference, providing a thread-safe way to get the server's state.

      Returns:
      the current status as an XTableStatus object
    • isDebug

      public boolean isDebug()
      Checks if debug mode is enabled.
      Returns:
      boolean - true if debug mode is enabled, false otherwise. This method retrieves the current value of the debug mode flag.
    • setDebug

      public void setDebug(boolean value)
      Sets the debug mode state.
      Parameters:
      value - boolean - the value to set for debug mode. This method sets the debug mode flag to the provided value. When enabled, the system starts publishing logs to the clients for debugging purposes.