public static void messageReceived(Holder holder, ChannelHandlerContext ctx,
MobileStateHolder state, StringMessage message) {
String[] split = split2(message.body);
if (split.length < 2) {
throw new IllegalCommandException("Wrong income message format.");
}
int dashId = Integer.parseInt(split[0]);
int deviceId = Integer.parseInt(split[1]);
User user = state.user;
DashBoard dash = state.user.profile.getDashByIdOrThrow(dashId);
log.debug("Deleting device with id {}.", deviceId);
Device device = user.profile.deleteDevice(dash, deviceId);
user.profile.cleanPinStorageForDevice(deviceId);
user.profile.deleteDeviceFromTags(dash, deviceId);
holder.tokenManager.deleteDevice(device);
Session session = holder.sessionDao.get(state.userKey);
session.closeHardwareChannelByDeviceId(dashId, deviceId);
user.lastModifiedTs = System.currentTimeMillis();
holder.blockingIOProcessor.executeHistory(() -> {
try {
holder.reportingDiskDao.delete(user, dashId, deviceId);
} catch (Exception e) {
log.warn("Error removing device data. Reason : {}.", e.getMessage());
}
});
ctx.writeAndFlush(ok(message.id), ctx.voidPromise());
}