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 TypeMethodDescriptionvoid
Close the server connection.void
connectClient
(String ip, int port, Runnable success) Connect to a server.void
Disconnect from the server.void
discoverServers
(Cons<Host> callback, Runnable done) Discover servers.default void
dispose()
Close all connections.Iterable<? extends NetConnection>
Return all connected users.void
hostServer
(int port) Host a server at specified port.void
Ping a host.void
sendClient
(Object object, boolean reliable) Send an object to the server.default void
setConnectFilter
(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
Sets a connection filter by IP address. If the filter returnsfalse
, the connection will be closed.
-