Package org.omegazero.net.util
Class LoopbackClientManager
java.lang.Object
org.omegazero.net.util.LoopbackClientManager
- All Implemented Interfaces:
Runnable,NetClientManager,NetworkApplication
NetClientManager implementation for loopback sockets.- Since:
- 2.3.1
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLoopbackClientManager(Function<SocketConnection, Consumer<Runnable>> workerCreator, LoopbackServer server) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this application, closing all bound and connected sockets and stopping the main loop, causing a call toNetworkApplication.start()to return.connection(ConnectionParameters params) Creates a new connection instance based on the given parameters to be managed by thisNetClientManager.voidinit()Initializes this application.voidstart()Runs the main loop of this instance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.omegazero.net.common.NetworkApplication
run
-
Constructor Details
-
LoopbackClientManager
public LoopbackClientManager(Function<SocketConnection, Consumer<Runnable>> workerCreator, LoopbackServer server)
-
-
Method Details
-
getServer
-
init
public void init()Description copied from interface:NetworkApplicationInitializes this application.- Specified by:
initin interfaceNetworkApplication
-
close
public void close()Description copied from interface:NetworkApplicationCloses this application, closing all bound and connected sockets and stopping the main loop, causing a call toNetworkApplication.start()to return.- Specified by:
closein interfaceNetworkApplication
-
start
public void start()Description copied from interface:NetworkApplicationRuns the main loop of this instance. This loop processes incoming or outgoing connection requests and network traffic.Under normal circumstances, never returns before
NetworkApplication.close()is called. Afterclose()is called, this function should return as soon as possible.If this method is called before
NetworkApplication.init(), the behavior is undefined.- Specified by:
startin interfaceNetworkApplication
-
connection
Description copied from interface:NetClientManagerCreates a new connection instance based on the given parameters to be managed by thisNetClientManager.SocketConnection.connect(int)will need to be called on the returned connection instance to initiate the connection.- Specified by:
connectionin interfaceNetClientManager- Parameters:
params- Parameters for this connection- Returns:
- The new connection instance
- Throws:
IOException- If an error occurs while creating the connection. Subsequent network errors (for example, because the server refused the connection) are usually passed to theonErrorcallback of the new connection instead
-