Package mindustry.net
Interface Net.NetProvider
- All Known Implementing Classes:
ArcNetProvider
- Enclosing class:
- Net
public static interface Net.NetProvider
Networking implementation.
-
Method Summary
Modifier and TypeMethodDescriptionvoidClose the server connection.voidconnectClient(String ip, int port, Runnable success) Connect to a server.voidDisconnect from the server.voiddiscoverServers(arc.func.Cons<Host> callback, Runnable done) Discover servers.default voiddispose()Close all connections.default arc.net.Server.ServerConnectFilterIterable<? extends NetConnection>Return all connected users.voidhostServer(int port) Host a server at specified port.voidPing a host.voidsendClient(Object object, boolean reliable) Send an object to the server.default voidsetConnectFilter(arc.net.Server.ServerConnectFilter connectFilter) Sets a connection filter by IP address.
-
Method Details
-
connectClient
Connect to a server.- Throws:
IOException
-
sendClient
Send an object to the server. -
disconnectClient
void disconnectClient()Disconnect from the server. -
discoverServers
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
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
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(arc.net.Server.ServerConnectFilter connectFilter) Sets a connection filter by IP address. If the filter returnsfalse, the connection will be closed. -
getConnectFilter
@Nullable default arc.net.Server.ServerConnectFilter getConnectFilter()
-