package org.kne.cloud.network.klalb;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.zip.Deflater;
import java.util.zip.DeflaterInputStream;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;

import org.kne.cloud.network.SocketBridge;
import org.kne.cloud.network.StreamBridge;

public class CompressedSocketBridge extends SocketBridge {

	public CompressedSocketBridge(Socket a, Socket b) throws IOException {
		super(a, b);
	}

	@Override
	protected void createStreamBridge() throws IOException {
		bridgeAB = new StreamBridge(a.getInputStream(),new DeflaterOutputStream( b.getOutputStream(), new Deflater(Deflater.BEST_COMPRESSION, true), true) );
		bridgeBA = new StreamBridge(new InflaterInputStream( b.getInputStream(), new Inflater(true)) , a.getOutputStream());
	}

	
}
