use of org.thingsboard.server.transport.coap.callback.CoapOkCallback in project thingsboard by thingsboard.
the class CoapTransportResource method handleToDeviceRpcResponse.
private void handleToDeviceRpcResponse(TbCoapClientState clientState, CoapExchange exchange, Request request) throws AdaptorException {
TransportProtos.SessionInfoProto session = clientState.getSession();
if (session == null) {
session = clients.getNewSyncSession(clientState);
}
UUID sessionId = toSessionId(session);
transportService.process(session, clientState.getAdaptor().convertToDeviceRpcResponse(sessionId, request, clientState.getConfiguration().getRpcResponseMsgDescriptor()), new CoapOkCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
}
use of org.thingsboard.server.transport.coap.callback.CoapOkCallback in project thingsboard by thingsboard.
the class DefaultCoapClientContext method cancelAttributeSubscription.
private void cancelAttributeSubscription(TbCoapClientState state) {
if (state.getAttrs() != null) {
clientsByToken.remove(state.getAttrs().getToken());
CoapExchange exchange = state.getAttrs().getExchange();
state.setAttrs(null);
transportService.process(state.getSession(), TransportProtos.SubscribeToAttributeUpdatesMsg.newBuilder().setUnsubscribe(true).build(), new CoapOkCallback(exchange, CoAP.ResponseCode.DELETED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
if (state.getRpc() == null) {
closeAndCleanup(state);
}
}
}
Aggregations