Package org.omegazero.net.util
Class LoopbackServer
java.lang.Object
org.omegazero.net.util.LoopbackServer
- All Implemented Interfaces:
Runnable,NetworkApplication,NetServer
NetServer implementation for loopback sockets.- Since:
- 2.3.1
- See Also:
-
Constructor Summary
Constructors -
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.voidinit()Initializes this application.protected voidvoidsetConnectionCallback(Consumer<SocketConnection> handler) Sets the callback for a new incoming connection.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
-
LoopbackServer
-
-
Method Details
-
newConnection
-
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
-
setConnectionCallback
Description copied from interface:NetServerSets the callback for a new incoming connection.The first parameter of this callback is an
SocketConnectioninstance representing the new connection from the client.This method must be called before
NetworkApplication.start(), otherwise, behavior is undefined.- Specified by:
setConnectionCallbackin interfaceNetServer- Parameters:
handler- The connection callback
-