sessions, fonctionnent (dans certains cas précis, de manière limitée dans le temps).
57 line
1.5 KiB
Java
57 line
1.5 KiB
Java
package clavardage;
|
|
import reseau.*;
|
|
|
|
public class SessionClavardage {
|
|
private String idSource = null;
|
|
private String idDestination = null;
|
|
private TCPClient clientEmission = null;
|
|
private TCPClient clientReception = null;
|
|
|
|
public SessionClavardage(String idSource, String idDestination, TCPClient clientEmission, TCPClient clientReception) {
|
|
this.idSource = idSource;
|
|
this.idDestination = idDestination;
|
|
this.clientEmission = clientEmission;
|
|
this.clientReception = clientReception;
|
|
}
|
|
|
|
public SessionClavardage(String idSource, String idDestination, TCPClient clientReception) {
|
|
this.idSource = idSource;
|
|
this.idDestination = idDestination;
|
|
this.clientReception = clientReception;
|
|
}
|
|
|
|
public void send(String message) {
|
|
this.clientEmission.send(message);
|
|
}
|
|
|
|
public void stop() {
|
|
if (this.clientEmission != null) this.clientEmission.stop();
|
|
if (this.clientReception != null) this.clientReception.stop();
|
|
}
|
|
|
|
|
|
public String toString() {
|
|
return "Session entre " + this.idSource + " à l'adresse " + this.clientEmission.getAdresseSource()
|
|
+ ", et " + this.idDestination + " à l'adresse " + this.clientEmission.getAdresseCible() + "\n";
|
|
}
|
|
|
|
public String getIdSource() {
|
|
return this.idSource;
|
|
}
|
|
|
|
public String getIdDestination() {
|
|
return this.idDestination;
|
|
}
|
|
|
|
public TCPClient getClientReception() {
|
|
return this.clientReception;
|
|
}
|
|
|
|
public void setClientReception(TCPClient client) {
|
|
this.clientReception = client;
|
|
}
|
|
|
|
//public void run() {
|
|
|
|
//}
|
|
}
|