1) can the interface also make the client implement runnable? like, could the interface implement runnable and then pass that on?
Yep. You can make an interface
inherit the properties of another interface
.
public interface IClient extends Runnable
2) can a class that implements my interface, lets say the class is called test, could i have my server use that class as a parameter? (i'm bad at wording my questions, so here is an example)
Yes you could, and the code you provided should work.
But what I think you want to do is..
Remember, the important thing is that you keep the model in mind. That model is the client-server
model. That means, the server acts as the switch for all of the clients, but it's the client that requests the connection from the server. It goes something like this.
public class Client implements IClient
{
public void haha()
{
// Prints a value to the server.
getConnection().writeline("hi");
}
public BufferedWriter getConnection()
{
// Here you request a connection from the server.
String ip = "10.20.50.60"; // Example.
// Get the connection via your own classes.
BufferedWriter out = new BufferedWriter(getOutputStream(ip));
return out;
}
private OutputStream getOutputStream(String ip)
{
// Logic to get the socket stream pointing to the server.
}
}
And the server
will have a method to recieve this data, and decide what to do with it, and do that, it needs to have a slave
listening on the stream your client is writing to. The slave listens, obtains data and passes onto the logic. The logic decides what to do, and passes onto a writing class that outputs to the appropriate stream.