public final class DOFServer
extends java.lang.Object
DOF.createServer(org.opendof.core.oal.DOFServer.Config)
or from
an existing server with createServer(org.opendof.core.oal.DOFServer.Config)
.
Unicast servers require a unique transport address. Multicast servers are permitted to share a transport
address for received packets but rely on their related unicast server to keep their sent traffic unique. For more information on
properly creating multicast groups, see DOFConnection.Type.DATAGRAM
and DOFConnection.Type.GROUP
DOF
,
DOFConnection
Modifier and Type | Class and Description |
---|---|
static class |
DOFServer.Config
This class represents server configuration options.
|
static interface |
DOFServer.StartOperationListener
This interface is used for the completion notification for asynchronous
start requests.
|
static interface |
DOFServer.State
This class represents the instantaneous state of the server at a given time.
|
static interface |
DOFServer.StateListener
StateListener is used for notification purposes when a server's state changes.
|
static class |
DOFServer.Type
This enumeration lists the types of servers.
|
Modifier and Type | Method and Description |
---|---|
void |
addStateListener(DOFServer.StateListener stateListener)
Add a
DOFServer.StateListener . |
DOFOperation.Start |
beginRestart(int timeout)
Restart a server, waiting up to timeout for the server to be restarted.
|
DOFOperation.Start |
beginRestart(int timeout,
DOFServer.StartOperationListener operationListener)
Restart a server, waiting up to timeout for the server to be restarted.
|
DOFOperation.Start |
beginRestart(int timeout,
DOFServer.StartOperationListener operationListener,
java.lang.Object context)
Restart a server, waiting up to timeout for the server to be restarted.
|
DOFOperation.Start |
beginStart(int timeout)
Start a server, waiting up to timeout for the server to be started.
|
DOFOperation.Start |
beginStart(int timeout,
DOFServer.StartOperationListener operationListener)
Start a server, waiting up to timeout for the server to be started.
|
DOFOperation.Start |
beginStart(int timeout,
DOFServer.StartOperationListener operationListener,
java.lang.Object context)
Start a server, waiting up to timeout for the server to be started.
|
DOFConnection |
createConnection(DOFConnection.Config config)
Create one of the following connections related to this server.
|
DOFServer |
createServer(DOFServer.Config config)
Create a server related to this server.
|
void |
destroy()
Destroy is used to clean up resources allocated during DOFServer creation.
|
boolean |
equals(java.lang.Object obj) |
int |
getConnectionCount()
Get the current number of connections connected to this server.
|
java.util.List<DOFConnection> |
getConnections()
Get the list of connections connected to this server.
|
DOFServer |
getRelatedServer()
Multicast groups require a related DOFServer.
|
DOFServer.State |
getState()
Get the current instantaneous state of the server.
|
int |
hashCode() |
boolean |
isStarted()
Return whether the server is currently started.
|
void |
removeStateListener(DOFServer.StateListener stateListener)
Remove a
DOFServer.StateListener from this server. |
void |
restart(int timeout)
Restarts the server synchronously, but only waiting for the specified timeout.
|
void |
start(int timeout)
Starts the server synchronously, but only waiting for the specified timeout.
|
void |
stop()
Stops the server.
|
java.lang.String |
toString() |
public void destroy()
DOF.destroy()
. Any attempt to use a destroyed DOFServer will
result in undefined behavior.public void start(int timeout) throws DOFException
timeout
- Maximum time to wait, in milliseconds, for the server to start. Must be >= 0.DOFException
- If the server cannot be started.stop()
public boolean isStarted()
public void restart(int timeout) throws DOFException
timeout
- Maximum time to wait, in milliseconds, for the server to restart. Must be >= 0.DOFException
- If the server cannot be started.stop()
public DOFOperation.Start beginStart(int timeout)
DOFOperation.waitComplete()
can be called on the returned operation to wait for it to complete.
Will also start any related server using the specified parameters..timeout
- Maximum time to wait, in milliseconds, for the server to be started.public DOFOperation.Start beginStart(int timeout, DOFServer.StartOperationListener operationListener)
timeout
- Maximum time to wait, in milliseconds, for the server to be started. Note, however, that the server
may still start if the underlying transport cannot cancel the request. Must be >= 0. Zero
is allowed, in which case the operationListener is immediately called indicating the current state.operationListener
- An associated completion operationListener. This may be null.public DOFOperation.Start beginStart(int timeout, DOFServer.StartOperationListener operationListener, java.lang.Object context)
timeout
- Maximum time to wait, in milliseconds, for the server to be started. Note, however, that the server
may still start if the underlying transport cannot cancel the request. Must be >= 0. Zero
is allowed, in which case the operationListener is immediately called indicating the current state.operationListener
- An associated completion operationListener. This may be null.context
- Context data associated with the operationListener. The context will be passed back to the operationListener.public DOFOperation.Start beginRestart(int timeout)
DOFOperation.waitComplete()
can be called on the returned operation to wait for it to complete.
Will also start any related server.timeout
- Maximum time to wait, in milliseconds, for the server to be restarted.public DOFOperation.Start beginRestart(int timeout, DOFServer.StartOperationListener operationListener)
timeout
- Maximum time to wait, in milliseconds, for the server to be restarted. Note, however, that the server
may still start if the underlying transport cannot cancel the request. Must be >= 0. Zero
is allowed, in which case the operationListener is immediately called indicating the current state.operationListener
- An associated completion operationListener. This may be null.public DOFOperation.Start beginRestart(int timeout, DOFServer.StartOperationListener operationListener, java.lang.Object context)
timeout
- Maximum time to wait, in milliseconds, for the server to be restarted. Note, however, that the server
may still start if the underlying transport cannot cancel the request. Must be >= 0. Zero
is allowed, in which case the operationListener is immediately called indicating the current state.operationListener
- An associated completion operationListener. This may be null.context
- Context data associated with the operationListener. The context will be passed back to the operationListener.public void stop()
start(int)
public void addStateListener(DOFServer.StateListener stateListener)
DOFServer.StateListener
. The stateListener will be notified immediately with the current state of the server
and then on subsequent server state changes.
There is a possible race condition if you add the listener right after calling start(int)
. That is, your
listener may be called twice with the "started" state. It is preferable to add the listener before
calling start(). Your listener will then be called twice: once with a "!started" state and then again with "started".stateListener
- The listener that should be called with state changes. This must not be null.public void removeStateListener(DOFServer.StateListener stateListener)
DOFServer.StateListener
from this server. The listener will soon
stop receiving updates.stateListener
- The listener that should no longer be called. This must not be null.public DOFServer.State getState()
public int getConnectionCount()
public java.util.List<DOFConnection> getConnections()
public DOFConnection createConnection(DOFConnection.Config config)
DOFConnection.Type.DATAGRAM
).DOFConnection.Type.GROUP
).DOFConnection.Type.HUB
). For creating a DOFConnection.Type.POINT
,
see DOFConnection.createConnection(org.opendof.core.oal.DOFConnection.Config)
.config
- The configuration options of the connection. Must not be null.DOFConnection.Type.DATAGRAM_STATELESS
,
DOFConnection.Type.GROUP
,
DOFConnection.Type.HUB
public DOFServer createServer(DOFServer.Config config)
DOFConnection.Type.DATAGRAM
).DOFConnection.Type.GROUP
).config
- The configuration options of the server. Must not be null.public DOFServer getRelatedServer()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object