use of org.eclipse.leshan.core.response.BootstrapDeleteResponse in project leshan by eclipse.
the class BootstrapHandler method sendDelete.
private void sendDelete(final BootstrapSession session, final BootstrapConfig cfg) {
final BootstrapDeleteRequest deleteRequest = new BootstrapDeleteRequest();
send(session, deleteRequest, new ResponseCallback<BootstrapDeleteResponse>() {
@Override
public void onResponse(BootstrapDeleteResponse response) {
LOG.trace("Bootstrap delete {} return code {}", session.getEndpoint(), response.getCode());
List<Integer> toSend = new ArrayList<>(cfg.security.keySet());
sendBootstrap(session, cfg, toSend);
}
}, new ErrorCallback() {
@Override
public void onError(Exception e) {
LOG.debug(String.format("Error during bootstrap delete '/' on %s", session.getEndpoint()), e);
sessionManager.failed(session, DELETE_FAILED, deleteRequest);
}
});
}
use of org.eclipse.leshan.core.response.BootstrapDeleteResponse in project leshan by eclipse.
the class RootResource method handleDELETE.
@Override
public void handleDELETE(CoapExchange exchange) {
if (!StringUtils.isEmpty(exchange.getRequestOptions().getUriPathString())) {
exchange.respond(ResponseCode.METHOD_NOT_ALLOWED);
return;
}
ServerIdentity identity = ResourceUtil.extractServerIdentity(exchange, bootstrapHandler);
BootstrapDeleteResponse response = bootstrapHandler.delete(identity, new BootstrapDeleteRequest());
exchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage());
}
Aggregations