Package it.polimi.ingsw.view.socket
Class Connection
- java.lang.Object
-
- it.polimi.ingsw.utils.Observable<String>
-
- it.polimi.ingsw.view.socket.Connection
-
-
Constructor Summary
Constructors Constructor Description Connection(String ip, int port)Connection Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()close socketbooleangetStatus()Get Socket connectionvoidrun()Function to handle push data from server, then notify to all observers of this connectionvoidsend(String toSend)Send a data in the socketvoidsetMaster(AppInterface master)Set Connection Ownervoidupdate(String toSend)Function triggered when need send data to server-
Methods inherited from class it.polimi.ingsw.utils.Observable
addObservers, addObservers, notify, notify
-
-
-
-
Constructor Detail
-
Connection
public Connection(String ip, int port) throws IOException
Connection Constructor- Parameters:
ip- server ipport- server port- Throws:
IOException- init fail
-
-
Method Detail
-
setMaster
public void setMaster(AppInterface master)
Set Connection Owner- Parameters:
master- owner
-
send
public void send(String toSend)
Send a data in the socket- Parameters:
toSend- data to send
-
getStatus
public boolean getStatus()
Get Socket connection- Returns:
- socket connection
-
close
public void close()
close socket- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
run
public void run()
Function to handle push data from server, then notify to all observers of this connection
-
-