package org.kne.cloud.network.minecraft;

import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import org.kne.cloud.network.HostPortMap;
import org.kne.cloud.network.MultipurposeSocketAddress;
import org.kne.cloud.network.SocketToSocketProxy;

public class MinecraftSocketToSocketProxy extends SocketToSocketProxy {
	private List<Function<MinecraftPacket,MinecraftPacket>> transformersAB=new ArrayList<Function<MinecraftPacket,MinecraftPacket>>();
	private List<Function<MinecraftPacket,MinecraftPacket>> transformersBA=new ArrayList<Function<MinecraftPacket,MinecraftPacket>>();
	public List<Function<MinecraftPacket, MinecraftPacket>> getTransformersAB() {
		return transformersAB;
	}

	public List<Function<MinecraftPacket, MinecraftPacket>> getTransformersBA() {
		return transformersBA;
	}

	public MinecraftSocketToSocketProxy(MultipurposeSocketAddress listen, MultipurposeSocketAddress cbind,
			MultipurposeSocketAddress defaultConnect, Map<String, MultipurposeSocketAddress> detectedConnect)
			throws IOException {
		super(listen, cbind, defaultConnect, detectedConnect);
	}

	public MinecraftSocketToSocketProxy(MultipurposeSocketAddress listen, MultipurposeSocketAddress cbind,
			MultipurposeSocketAddress defaultConnect) throws IOException {
		super(listen, cbind, defaultConnect);
	}

	public MinecraftSocketToSocketProxy(MultipurposeSocketAddress listen, MultipurposeSocketAddress connect)
			throws IOException {
		super(listen, connect);
	}

	public MinecraftSocketToSocketProxy(String l, String r) throws IOException {
		super(l, r);
	}

	

	@Override
	protected void runBridge(Socket sk, Socket sox) throws IOException {//new KLALBJsonMotdInserter(()->{return kc.getSelf();},()->{return 23333;})
		MinecraftSocketBridge dsb=new MinecraftSocketBridge(sk,sox);
		dsb.getBridgeAB().getTransformers().addAll(transformersAB);
		dsb.getBridgeBA().getTransformers().addAll(transformersBA);
		dsb.run();
	}
	
}
