private void sendInternal( final IByteStreamConnection connection, final TransferDescription description, byte[] payload) throws IOException { boolean sendPacket = true; for (IPacketInterceptor packetInterceptor : packetInterceptors) sendPacket &= packetInterceptor.sendPacket(description, payload); if (!sendPacket) return; long sizeUncompressed = payload.length; if (description.compressContent()) payload = deflate(payload); final long transferStartTime = System.currentTimeMillis(); try { connection.send(description, payload); } catch (IOException e) { LOG.error( "failed to send " + description + ", connection=" + connection + ":" + e.getMessage(), e); throw e; } notifyDataSent( connection.getMode(), payload.length, sizeUncompressed, System.currentTimeMillis() - transferStartTime); }
@Override public void receive(final BinaryXMPPExtension extension) { boolean dispatchPacket = true; for (IPacketInterceptor packetInterceptor : packetInterceptors) dispatchPacket &= packetInterceptor.receivedPacket(extension); if (!dispatchPacket) return; if (LOG.isTraceEnabled()) LOG.trace( "received binary XMPP extension: " + extension.getTransferDescription() + ", size: " + extension.getCompressedSize() + ", RX time: " + extension.getTransferDuration() + " ms [" + extension.getTransferMode() + "]"); if (extension.getTransferDescription().compressContent()) { byte[] payload = extension.getPayload(); long compressedPayloadLenght = payload.length; try { payload = inflate(payload); } catch (IOException e) { LOG.error("could not decompress extension payload", e); return; } extension.setPayload(compressedPayloadLenght, payload); } notifyDataReceived( extension.getTransferMode(), extension.getCompressedSize(), extension.getUncompressedSize(), extension.getTransferDuration()); receiver.processBinaryXMPPExtension(extension); }