public interface ServerInterface
Resource
s.
A server hosts a tree of Resource
s which are exposed to clients by
means of one or more Endpoint
s which are bound to a network interface.
Resources can be added and removed from the server dynamically during runtime.
The server starts to process incoming CoAP requests after its start()
method has been invoked and does so until it is stopped again via its stop()
method.Modifier and Type | Method and Description |
---|---|
ServerInterface |
add(Resource... resources)
Adds one or more resources to the server.
|
void |
addEndpoint(Endpoint endpoint)
Adds an endpoint for receive and sending CoAP messages on.
|
void |
destroy()
Destroys the server, i.e. unbinds from all ports and frees all system
resources.
|
Endpoint |
getEndpoint(java.net.InetSocketAddress address)
Gets the endpoint bound to a particular address.
|
Endpoint |
getEndpoint(int port)
Gets an endpoint bound to a particular port.
|
java.util.List<Endpoint> |
getEndpoints()
Gets the endpoints this server is bound to.
|
boolean |
remove(Resource resource)
Removes a resource from the server.
|
void |
start()
Starts the server by starting all endpoints this server is assigned to.
|
void |
stop()
Stops the server, i.e. unbinds it from all ports.
|
void start()
java.lang.IllegalStateException
- if the server could not be started properly,
e.g. because none of its endpoints could be bound to their respective
portsvoid stop()
void destroy()
ServerInterface add(Resource... resources)
resources
- the resourcesboolean remove(Resource resource)
resource
- the resource to be removedtrue
if the resource has been removed successfullyvoid addEndpoint(Endpoint endpoint)
endpoint
- the endpointjava.lang.NullPointerException
- if the endpoint is null
java.util.List<Endpoint> getEndpoints()
Endpoint getEndpoint(java.net.InetSocketAddress address)
address
- the addressnull
if none of the
server's endpoints is bound to the given addressEndpoint getEndpoint(int port)
port
- the portnull
if none of the
server's endpoints is bound to the given port on any of its
network interfaces