Search in sources :

Example 1 with BootstrapDeleteResponse

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);
        }
    });
}
Also used : BootstrapDeleteRequest(org.eclipse.leshan.core.request.BootstrapDeleteRequest) BootstrapDeleteResponse(org.eclipse.leshan.core.response.BootstrapDeleteResponse) ErrorCallback(org.eclipse.leshan.core.response.ErrorCallback) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with BootstrapDeleteResponse

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());
}
Also used : BootstrapDeleteRequest(org.eclipse.leshan.core.request.BootstrapDeleteRequest) BootstrapDeleteResponse(org.eclipse.leshan.core.response.BootstrapDeleteResponse) ServerIdentity(org.eclipse.leshan.client.request.ServerIdentity)

Aggregations

BootstrapDeleteRequest (org.eclipse.leshan.core.request.BootstrapDeleteRequest)2 BootstrapDeleteResponse (org.eclipse.leshan.core.response.BootstrapDeleteResponse)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ServerIdentity (org.eclipse.leshan.client.request.ServerIdentity)1 ErrorCallback (org.eclipse.leshan.core.response.ErrorCallback)1