/** * Processes the file requests. * * @throws IOException The exception thrown if an i/o error occurs. */ public void processFileQueue() { FileRequestEvent request; synchronized (fileQueue) { request = fileQueue.pop(); if (fileQueue.isEmpty()) { idle = true; } else { service.addAudioContext(this); idle = false; } } if (request != null) { int type = request.getType(); int file = request.getFile(); int crc = request.getCrc(); int version = request.getVersion(); HttpVersion http = request.getHttp(); ByteBuf buf = Unpooled.buffer(); if (type == 255 && file == 255) { buf = Unpooled.wrappedBuffer(server.getCache().getChecksum()); } else { if (server.getCache().getReferenceTable(type).getEntry(file).getCrc() != crc || server.getCache().getReferenceTable(type).getEntry(file).getVersion() != version) { writeResponse(http, buf); return; } try { buf = Unpooled.wrappedBuffer(server.getCache().getStore().read(type, file)); if (type != 255) buf = buf.slice(0, buf.readableBytes() - 2); } catch (IOException e) { e.printStackTrace(); } } writeResponse(http, buf); } }
/** * Adds this {@link com.friz.update.network.UpdateSessionContext} to the {@link * com.friz.update.UpdateService}. */ public void addContextToService() { service.addAudioContext(this); }