package fr.upem.net.udp;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * Created by carayol on 04/02/15.
 */
public class OneByOneRequester extends Requester {


	private static final int BUFFER_SIZE = 1024;
	private static final int TIMEOUT = 300;

	private final BlockingQueue<ByteBuffer> queue = new ArrayBlockingQueue<ByteBuffer>(1);
	
	private final Thread listener = new Thread(() -> {
	  // TODO
	});

	public OneByOneRequester(InetSocketAddress serverAddress) {
		super(serverAddress);
	}

	@Override
	public void open() throws IOException {
		super.open();
		listener.start();
	}

	@Override
	public List<String> toUpperCase(List<String> list,Charset cs) throws IOException, InterruptedException {
		List<String> linesUpperCase = new ArrayList<>(list.size());
		for(int i=0;i<list.size();i++){
			linesUpperCase.add(toUpperCase(i,list.get(i),cs));
		}
		return linesUpperCase;
	}

	private String toUpperCase(long requestNumber, String s, Charset cs) throws IOException, InterruptedException {
	  // TODO
	}

	@Override
	public void close() throws IOException {
		super.close();
		listener.interrupt();
	}
}