java.lang.Object
java.util.Observable
Model.ClientCommunication
This class is responsible for the communication between the client and the server
It sends messages to the server and notifies the observers when a message is received
The protocol is: id:method:input1,input2,...
The id is the id of the client, -1 means that the client is not connected yet
-
Constructor Summary
ConstructorsConstructorDescriptionClientCommunication(String ip, int port, String name) Creates a new client communication with the server and starts a new thread to check for messages from the server -
Method Summary
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Constructor Details
-
ClientCommunication
public ClientCommunication() -
ClientCommunication
Creates a new client communication with the server and starts a new thread to check for messages from the server- Parameters:
ip- the host to connect toport- the port to connect to
-
-
Method Details
-
connect
-
send
Sends a message to the server, protocol: id:method:input1,input2,...- Parameters:
id- the id of the clientmethodName- the method name to callargs- the inputs to the method
-
close
public void close()close the socket connection to the server -> stop the thread
-