Package org.omegazero.net.client
Class UDPClientManager
java.lang.Object
org.omegazero.net.common.SelectorHandler
org.omegazero.net.common.ConnectionSelectorHandler
org.omegazero.net.client.UDPClientManager
- All Implemented Interfaces:
Runnable,NetClientManager,NetworkApplication
- Direct Known Subclasses:
DTLSClientManager,PlainUDPClientManager
public abstract class UDPClientManager
extends ConnectionSelectorHandler
implements NetClientManager
-
Field Summary
Fields -
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.connection(ConnectionParameters params) Creates 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.protected abstract ChannelConnectioncreateConnection(SelectionKey selectionKey, ConnectionParameters params) protected abstract voidCalled after a connect request on a connection.protected voidCalled when a key was selected in a select call in theSelectorHandler.runSelectorLoop()method.voidinit()Initializes this application.voidstart()Runs the main loop of this instance.Methods inherited from class org.omegazero.net.common.ConnectionSelectorHandler
handleConnectionClosed, loopIteration, onConnectionClosedMethods inherited from class org.omegazero.net.common.SelectorHandler
closeSelector, initSelector, isRunning, registerChannel, registerChannel, runSelectorLoop, selectorKeys, selectorWakeupMethods 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
-
Field Details
-
worker
-
-
Constructor Details
-
UDPClientManager
public UDPClientManager() -
UDPClientManager
-
-
Method Details
-
createConnection
protected abstract ChannelConnection createConnection(SelectionKey selectionKey, ConnectionParameters params) throws IOException - Throws:
IOException
-
handleConnect
Called after a connect request on a connection.- Parameters:
conn- TheChannelConnectionobject on which connect was called
-
init
Description copied from interface:NetworkApplicationInitializes this application.- Specified by:
initin interfaceNetworkApplication- Throws:
IOException- If an IO error occurs during initialization
-
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- Throws:
IOException- If an IO error occurs
-
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, should never return beforeNetworkApplication.close()is called. Afterclose()is called, this function should return as soon as possible.
If this method is called beforeNetworkApplication.init(), the behavior is undefined.- Specified by:
startin interfaceNetworkApplication- Throws:
IOException- If an IO error occurs during any networking operation
-
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
-
handleSelectedKey
Description copied from class:SelectorHandlerCalled when a key was selected in a select call in theSelectorHandler.runSelectorLoop()method.- Specified by:
handleSelectedKeyin classSelectorHandler- Parameters:
key- The selected key- Throws:
IOException- If an IO error occurs
-