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 void
close()
close socketboolean
getStatus()
Get Socket connectionvoid
run()
Function to handle push data from server, then notify to all observers of this connectionvoid
send(String toSend)
Send a data in the socketvoid
setMaster(AppInterface master)
Set Connection Ownervoid
update(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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
run
public void run()
Function to handle push data from server, then notify to all observers of this connection
-
-