package no.ntnu.fp.net.network.client; import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingQueue; import no.ntnu.fp.model.Authenticate; import no.ntnu.fp.net.network.TestCommunicationClient; /**/ public class Client implements Runnable { //fields private Socket mySocket; private int port; private String host; //private BlockingQueue<Object > inQueue; private DataOutputStream os; private ObjectOutputStream oos; private CommunicationController communicationController; private LinkedBlockingDeque<Object> testQueue; //Constructor public Client(String host, int port, LinkedBlockingDeque<Object> testQueue, CommunicationController communicationController){ this.testQueue = testQueue; try { this.mySocket = new Socket(InetAddress.getByName(host), port); this.communicationController = communicationController; this.host = host; this.port = port; } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public Socket getSocket() { return mySocket; } public void setHost(String ip) { this.host = ip; } //TODO: Stop these threads @Override public void run() { (new Thread(new ClientWorker(mySocket, testQueue, communicationController))).start(); (new Thread(new InternalReceiver(mySocket, testQueue))).start(); } }