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 TypeMethodDescriptionvoid
close()
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 ChannelConnection
createConnection
(SelectionKey selectionKey, ConnectionParameters params) protected abstract void
Called after a connect request on a connection.protected void
Called when a key was selected in a select call in theSelectorHandler.runSelectorLoop()
method.void
init()
Initializes this application.void
start()
Runs the main loop of this instance.Methods inherited from class org.omegazero.net.common.ConnectionSelectorHandler
handleConnectionClosed, loopIteration, onConnectionClosed
Methods inherited from class org.omegazero.net.common.SelectorHandler
closeSelector, initSelector, isRunning, registerChannel, registerChannel, runSelectorLoop, selectorKeys, selectorWakeup
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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
- TheChannelConnection
object on which connect was called
-
init
Description copied from interface:NetworkApplication
Initializes this application.- Specified by:
init
in interfaceNetworkApplication
- Throws:
IOException
- If an IO error occurs during initialization
-
close
Description copied from interface:NetworkApplication
Closes this application, closing all bound and connected sockets and stopping the main loop, causing a call toNetworkApplication.start()
to return.- Specified by:
close
in interfaceNetworkApplication
- Throws:
IOException
- If an IO error occurs
-
start
Description copied from interface:NetworkApplication
Runs 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:
start
in interfaceNetworkApplication
- Throws:
IOException
- If an IO error occurs during any networking operation
-
connection
Description copied from interface:NetClientManager
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.- Specified by:
connection
in interfaceNetClientManager
- Parameters:
params
- Parameters for this connection- Returns:
- The new connection instance
- Throws:
IOException
-
handleSelectedKey
Description copied from class:SelectorHandler
Called when a key was selected in a select call in theSelectorHandler.runSelectorLoop()
method.- Specified by:
handleSelectedKey
in classSelectorHandler
- Parameters:
key
- The selected key- Throws:
IOException
- If an IO error occurs
-