Class AbstractCommServer

java.lang.Object
com.illumon.util.net.AbstractCommServer
All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, CommServer
Direct Known Subclasses:
WebSocketCommProxy, WSCommServer

public abstract class AbstractCommServer extends Object implements CommServer
Abstract base class for CommServer impls, like fishlib and websocket. Members copied from fishlib's Server verbatim.
  • Field Details

    • name

      protected final String name
      the name of this server
    • log

      protected final com.fishlib.io.logger.Logger log
      the logger
  • Constructor Details

    • AbstractCommServer

      public AbstractCommServer(String name, com.fishlib.io.logger.Logger log)
  • Method Details

    • putHandler

      protected CommandHandler putHandler(String serviceId, CommandHandler handler)
      return the handler for a service ID
    • getHandler

      protected CommandHandler getHandler(String serviceId)
      return the handler for a service ID
    • addClientEntry

      public void addClientEntry(ClientEntry c)
      add a client to the list
      Specified by:
      addClientEntry in interface CommServer
    • removeClientEntry

      protected void removeClientEntry(ClientEntry c)
      remove a client to the list
    • getClients

      protected ClientEntry[] getClients()
      return an array of all clients
    • getName

      public String getName()
    • sendCommand

      public void sendCommand(String serviceId, com.fishlib.base.Command cmd)
      Send a command to all clients for a specified service.
      Specified by:
      sendCommand in interface CommServer
    • sendCommand

      public void sendCommand(String serviceId, com.fishlib.base.Command cmd, int sendTo)
      Send a command to all clients for a specified service which also match the sendTo flag
      Specified by:
      sendCommand in interface CommServer
    • sendCommand

      public boolean sendCommand(ClientEntry client, String serviceId, com.fishlib.base.Command cmd, boolean allowFlush)
      Send a command to a specific client. The serviceId is not checked before sending the message, but it is passed along to the client's processCommand() method.
      Specified by:
      sendCommand in interface CommServer
    • getClientSet

      public List<ClientEntry> getClientSet()
      Return the set of connected clients
      Specified by:
      getClientSet in interface CommServer
    • addCommandHandler

      public void addCommandHandler(String id, CommandHandler commandHandler)
      Add a new command handler to this server.
      Specified by:
      addCommandHandler in interface CommServer
    • removeCommandHandler

      public void removeCommandHandler(String id)
      Remove a command handler from this server.
      Specified by:
      removeCommandHandler in interface CommServer
    • disconnect

      public void disconnect() throws IOException
      Specified by:
      disconnect in interface CommServer
      Throws:
      IOException
    • TEST_SOCKET_CLOSE

      public void TEST_SOCKET_CLOSE()
      disconnect all clients, but leave the server socket open
      Specified by:
      TEST_SOCKET_CLOSE in interface CommServer