Package mindustry.net

Interface Net.NetProvider

All Known Implementing Classes:
ArcNetProvider
Enclosing class:
Net

public static interface Net.NetProvider
Networking implementation.
  • Method Details

    • connectClient

      void connectClient(String ip, int port, Runnable success) throws IOException
      Connect to a server.
      Throws:
      IOException
    • sendClient

      void sendClient(Object object, boolean reliable)
      Send an object to the server.
    • disconnectClient

      void disconnectClient()
      Disconnect from the server.
    • discoverServers

      void discoverServers(Cons<Host> callback, Runnable done)
      Discover servers. This should run the callback regardless of whether any servers are found. Should not block. Callback should be run on the main thread.
      Parameters:
      done - is the callback that should run after discovery.
    • pingHost

      void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> failed)
      Ping a host. If an error occurred, failed() should be called with the exception. This method should block. If the port is the default mindustry port (6567), SRV records are checked too.
    • hostServer

      void hostServer(int port) throws IOException
      Host a server at specified port.
      Throws:
      IOException
    • getConnections

      Iterable<? extends NetConnection> getConnections()
      Return all connected users.
    • closeServer

      void closeServer()
      Close the server connection.
    • dispose

      default void dispose()
      Close all connections.
    • setConnectFilter

      default void setConnectFilter(Server.ServerConnectFilter connectFilter)
      Sets a connection filter by IP address. If the filter returns false, the connection will be closed.