Compare commits
1 commit
master
...
version_2(
Author | SHA1 | Date | |
---|---|---|---|
34f15aefd2 |
35 changed files with 17 additions and 541 deletions
|
@ -1,14 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
<attributes>
|
|
||||||
<attribute name="module" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="lib" path="C:/Program Files (x86)/MySQL/Connector J 8.0/mysql-connector-java-8.0.22.jar"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Program Files/tyrus-standalone-client-1.9.jar"/>
|
|
||||||
<classpathentry kind="lib" path="C:/Program Files/javax.websocket-client-api-1.1.jar"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
|
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
3
Application/Clavardage/bin/.gitignore
vendored
3
Application/Clavardage/bin/.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
/websocket/
|
|
||||||
/controller/
|
/controller/
|
||||||
|
/model/
|
||||||
|
/view/
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,7 +8,6 @@ import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
@ -18,7 +17,6 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
//import javax.websocket.DeploymentException;
|
|
||||||
|
|
||||||
import model.Chat;
|
import model.Chat;
|
||||||
import model.LocalUser;
|
import model.LocalUser;
|
||||||
|
@ -26,7 +24,6 @@ import model.Message;
|
||||||
import model.Msg_Text;
|
import model.Msg_Text;
|
||||||
import model.RemoteUser;
|
import model.RemoteUser;
|
||||||
import view.Interface;
|
import view.Interface;
|
||||||
//import websocket.Appel;
|
|
||||||
|
|
||||||
public class Controller {
|
public class Controller {
|
||||||
|
|
||||||
|
@ -500,22 +497,17 @@ public class Controller {
|
||||||
ArrayList<Controller> lstCtr = new ArrayList<Controller>();
|
ArrayList<Controller> lstCtr = new ArrayList<Controller>();
|
||||||
|
|
||||||
// REMOTE USERS
|
// REMOTE USERS
|
||||||
/*
|
|
||||||
Controller ctr1 = new Controller(31011,portUDPlistening_remoteUsr1,31021,"Theau",histoire);
|
Controller ctr1 = new Controller(31011,portUDPlistening_remoteUsr1,31021,"Theau",histoire);
|
||||||
lstCtr.add(ctr1);
|
lstCtr.add(ctr1);
|
||||||
|
|
||||||
Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Leonie",histoire);
|
Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Leonie",histoire);
|
||||||
lstCtr.add(ctr2);
|
lstCtr.add(ctr2);
|
||||||
|
|
||||||
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alexandre",histoire);
|
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alexandre",histoire);
|
||||||
lstCtr.add(ctr3);
|
lstCtr.add(ctr3);
|
||||||
*/
|
|
||||||
// LOCAL USER
|
// LOCAL USER
|
||||||
Controller ctr = new Controller(31014,portUDPlistening_local,31024,histoire);
|
Controller ctr = new Controller(31014,portUDPlistening_local,31024,histoire);
|
||||||
lstCtr.add(ctr);
|
lstCtr.add(ctr);
|
||||||
|
|
||||||
//Appel app=new Appel();
|
|
||||||
//app.test();
|
|
||||||
|
|
||||||
/** Loop **/
|
/** Loop **/
|
||||||
Boolean running = isRunning(lstCtr);
|
Boolean running = isRunning(lstCtr);
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package controller;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class ListeningThread extends Thread{
|
|
||||||
|
|
||||||
protected Controller controller;
|
|
||||||
|
|
||||||
public ListeningThread(String s,Controller controller) {
|
|
||||||
super(s);
|
|
||||||
this.controller = controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void run();
|
|
||||||
|
|
||||||
public abstract void close();
|
|
||||||
}
|
|
|
@ -1,141 +0,0 @@
|
||||||
package controller;
|
|
||||||
|
|
||||||
import model.Chat;
|
|
||||||
import model.Msg_Text;
|
|
||||||
import model.RemoteUser;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ListeningThreadTCPChat extends ListeningThread{
|
|
||||||
|
|
||||||
private Socket socket;
|
|
||||||
|
|
||||||
/* CONSTRUCTOR OF ListeningThreadTCPConnection
|
|
||||||
* @parametres
|
|
||||||
* @param s : String => nom du thread
|
|
||||||
* @param myUser : User => utilisateur utilisant ce thread
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public ListeningThreadTCPChat(String s,Controller controller,Socket socket) {
|
|
||||||
super(s,controller);
|
|
||||||
this.socket=socket;
|
|
||||||
// TODO OpenSession si ouverture exterieur
|
|
||||||
}
|
|
||||||
|
|
||||||
/* run
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void run() {
|
|
||||||
/**** function variables ****/
|
|
||||||
BufferedReader in = null;
|
|
||||||
String msg = null;
|
|
||||||
String input;
|
|
||||||
String dateString;
|
|
||||||
Date date;
|
|
||||||
Calendar date1=Calendar.getInstance();
|
|
||||||
|
|
||||||
|
|
||||||
Chat c = null;
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
in =new BufferedReader(new InputStreamReader(this.socket.getInputStream()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
/************ Check rm user information **********/
|
|
||||||
// check data identification from rm user | TO REMOVE IF !=IP
|
|
||||||
int rmPortTCP = -1;
|
|
||||||
try {
|
|
||||||
rmPortTCP = Integer.parseInt(in.readLine());
|
|
||||||
} catch (NumberFormatException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
RemoteUser rm = new RemoteUser("Unknown",this.socket.getInetAddress(),rmPortTCP);
|
|
||||||
|
|
||||||
int indexRM = controller.myUser.getActiveUserIndexOf(rm);
|
|
||||||
// Check if rm is identifiable
|
|
||||||
/*System.out.println(rm);
|
|
||||||
for(int i=0;i<controller.myUser.getRemoteUsersList().size();i++) {
|
|
||||||
System.out.println(controller.myUser.getRemoteUsersList().get(i));
|
|
||||||
}
|
|
||||||
System.out.println(indexRM);*/
|
|
||||||
|
|
||||||
if(indexRM!=-1) {
|
|
||||||
rm = controller.myUser.getRemoteUsersList().get(indexRM);
|
|
||||||
// Check if chat already created
|
|
||||||
int indexChat = controller.myUser.getChatIndexOf(rm);
|
|
||||||
if(indexChat!=-1) {
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") Session déjà créer, on recupère le chat associé");
|
|
||||||
c = controller.myUser.getChats().get(indexChat);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
c=this.controller.openSession(rm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** listening tcp message from rm until session is close ***/
|
|
||||||
|
|
||||||
try {
|
|
||||||
String msgToprint;
|
|
||||||
while (!(input=in.readLine()).equals("end")/* && c.getActive()*/) {
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") recoit => "+rm.getPseudo()+" : "+input);
|
|
||||||
Msg_Text message = new Msg_Text(rm,input);
|
|
||||||
c.addMessage(message);
|
|
||||||
if(controller.activeChat==c) {
|
|
||||||
controller.view.notifyNewMessage("("+message.getDate()+")\n"+c.getRemoteUser().getPseudo()+" : "+input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") Remote User unidentifiable => CLOSING CONNECTION");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* ferme le socket d'écoute TCP pour le chat
|
|
||||||
* interrupt TCP listening thread pour le chat
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void close() {
|
|
||||||
try {
|
|
||||||
this.socket.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("End of listing thread UDP ("+this.controller.myUser.getPseudo()+")");
|
|
||||||
try {
|
|
||||||
this.interrupt();
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package controller;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.ServerSocket;
|
|
||||||
import java.net.Socket;
|
|
||||||
|
|
||||||
public class ListeningThreadTCPConnection extends ListeningThread{
|
|
||||||
|
|
||||||
private Socket socket_tcp=null;
|
|
||||||
private int nbChat = 0;
|
|
||||||
/* CONSTRUCTOR OF ListeningThreadTCPConnection
|
|
||||||
* @parametres
|
|
||||||
* @param s : String => nom du thread
|
|
||||||
* @param myUser : User => utilisateur utilisant ce thread
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public ListeningThreadTCPConnection(String s,Controller controller) {
|
|
||||||
super(s,controller);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void accept(ServerSocket servSocket) throws IOException {
|
|
||||||
Socket socket_tcp= servSocket.accept();
|
|
||||||
this.nbChat++;
|
|
||||||
ListeningThreadTCPChat threadtcpchat = new ListeningThreadTCPChat("Chat_of_"+controller.myUser.getPseudo()+"_"+nbChat,controller,socket_tcp);
|
|
||||||
threadtcpchat.start();
|
|
||||||
threadtcpchat.interrupt();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* run
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* écoutes les messages TCP tant que l'utilisateur est actif
|
|
||||||
* Traitement
|
|
||||||
* Si réception d'une demande, créer un thread pour la conversation
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void run(){
|
|
||||||
|
|
||||||
// Tant que l'utilisateur est actif on attends la demande de nouvelle conversation
|
|
||||||
ServerSocket servSocket=null;
|
|
||||||
try {
|
|
||||||
servSocket = new ServerSocket(controller.myUser.getPortTCP());
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") Server is listening on port "+this.controller.myUser.getPortTCP());
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") Server is not listening on port "+this.controller.myUser.getPortTCP());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
while(true) {
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") TCP Server waiting for new connection ...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.accept(servSocket);
|
|
||||||
System.out.println("("+this.controller.myUser.getPseudo()+") NEW CONNECTION");
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* ferme le socket d'écoute TCO
|
|
||||||
* interrupt UDP listening threadS
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void close() {
|
|
||||||
try {
|
|
||||||
this.socket_tcp.close();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
System.out.println("End of listing thread TCP ("+this.controller.myUser.getPseudo()+")");
|
|
||||||
try {
|
|
||||||
this.interrupt();
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
package controller;
|
|
||||||
|
|
||||||
import model.LocalUser;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.DatagramPacket;
|
|
||||||
import java.net.DatagramSocket;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
|
|
||||||
public class ListeningThreadUDP extends ListeningThread{
|
|
||||||
|
|
||||||
private DatagramSocket dgramSocket = null;
|
|
||||||
|
|
||||||
|
|
||||||
/* CONSTRUCTOR OF UserListeningThreadUDP
|
|
||||||
* @parametres
|
|
||||||
* @param s : String => nom du thread
|
|
||||||
* @param user : User => utilisateur utilisant ce thread
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* Appel du constructeur de la classe hérité
|
|
||||||
* Création d'un socket d'écoute UDP
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public ListeningThreadUDP(String s,Controller controller) {
|
|
||||||
super(s,controller);
|
|
||||||
try {
|
|
||||||
this.dgramSocket = new DatagramSocket(this.controller.myUser.getPortUDPlistening(),this.controller.myUser.getAddIP());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* run
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* écoutes les messages UDP tant que l'utilisateur est actif
|
|
||||||
* Traitement
|
|
||||||
* 1) Si demande d'information => envoi ses informations
|
|
||||||
* 2) Si réception d'information => ajoute les informations
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void run(){
|
|
||||||
|
|
||||||
// Tant que l'utilisateur est actif on attends les messages des nouveaux utilisateurs et changements des utilisateurs actifs
|
|
||||||
while(true) {
|
|
||||||
|
|
||||||
// Réception du message
|
|
||||||
byte[] buffer = new byte[256];
|
|
||||||
DatagramPacket inPacket= new DatagramPacket(buffer, buffer.length);
|
|
||||||
try {
|
|
||||||
dgramSocket.receive(inPacket);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
buffer = inPacket.getData();
|
|
||||||
|
|
||||||
// Traitement en fonction du message reçu
|
|
||||||
String receiveMsg = new String(buffer);
|
|
||||||
String [] tabMsg = receiveMsg.split(":");
|
|
||||||
|
|
||||||
|
|
||||||
// si demande d'information d'un nouvel utilisateur
|
|
||||||
if(tabMsg.length==3) {
|
|
||||||
InetAddress itsIP = null;
|
|
||||||
try {
|
|
||||||
itsIP = InetAddress.getByName(tabMsg[0].split("/")[1]); // On récupère l'adresse IP de l'utilisateur distant
|
|
||||||
} catch (UnknownHostException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
int senderUDPport = Integer.parseInt(tabMsg[1]); // On récupère le port UDP de l'utilisateur distant
|
|
||||||
|
|
||||||
String toSend = controller.myUser.getAddIP().toString()+":"+controller.myUser.getPortTCP()+":"+controller.myUser.getPseudo()+":test";
|
|
||||||
DatagramPacket outPacket= new DatagramPacket(toSend.getBytes(), toSend.length(),itsIP, senderUDPport);
|
|
||||||
|
|
||||||
try {
|
|
||||||
dgramSocket.send(outPacket);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si un nouvel utilisateur passe en mode actif ou changement d'information
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
// On récupère l'adresse IP et le port TCP de l'utilisateur distant et ajout à la liste de l'utilisateur utilisant ce thread
|
|
||||||
controller.myUser.addRemoteUser(InetAddress.getByName(tabMsg[0].split("/")[1]),Integer.parseInt(tabMsg[1]),tabMsg[2]);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(controller.interfaceRunning) {
|
|
||||||
controller.view.updateActiveUsers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close
|
|
||||||
* @description
|
|
||||||
* <p>
|
|
||||||
* Ferme le socket d'écoute UDP
|
|
||||||
* Interrompt le thread d'écoute UDP
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public void close() {
|
|
||||||
this.dgramSocket.close();
|
|
||||||
System.out.println("End of listing thread UDP ("+this.controller.myUser.getPseudo()+")");
|
|
||||||
try {
|
|
||||||
this.interrupt();
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package websocket;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
import javax.websocket.ContainerProvider;
|
|
||||||
import javax.websocket.DeploymentException;
|
|
||||||
import javax.websocket.Session;
|
|
||||||
import javax.websocket.WebSocketContainer;
|
|
||||||
|
|
||||||
|
|
||||||
public class Appel {
|
|
||||||
|
|
||||||
private WebSocketContainer container;
|
|
||||||
private Client client;
|
|
||||||
|
|
||||||
public void test() {
|
|
||||||
this.container= ContainerProvider.getWebSocketContainer();
|
|
||||||
this.client=new Client();
|
|
||||||
|
|
||||||
Session session=null;
|
|
||||||
try {
|
|
||||||
session=this.container.connectToServer(this.client, new URI ("ws://localhost:8082/WebSocket2/hello"));
|
|
||||||
} catch (DeploymentException | IOException | URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("pb avec le connect");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
this.client.onOpen(session, null);
|
|
||||||
this.client.sendMessage("hello from client");
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("pb avec le sendMessage");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package websocket;
|
|
||||||
|
|
||||||
public class Centralized {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
package websocket;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import javax.websocket.*;
|
|
||||||
|
|
||||||
public class Client extends Endpoint{
|
|
||||||
private Session session;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen (Session session, EndpointConfig config) {
|
|
||||||
this.session=session;
|
|
||||||
this.session.addMessageHandler(new MessageHandler.Whole<String>() {
|
|
||||||
@Override
|
|
||||||
public void onMessage (String msg) {
|
|
||||||
System.out.println("msg recu:"+msg);
|
|
||||||
};}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(String msg) throws IOException {
|
|
||||||
this.session.getBasicRemote().sendText(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
BIN
Composite_Diagram.jpg
Normal file
BIN
Composite_Diagram.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
Binary file not shown.
Before Width: | Height: | Size: 213 KiB |
Binary file not shown.
Before Width: | Height: | Size: 61 KiB |
45
README.md
45
README.md
|
@ -5,48 +5,3 @@ SYSTEME DE CLAVARDAGE DISTRIBUE INTERACTIF MULTI-UTILISATEUR TEMPS REEL
|
||||||
Alexandre Gonzalvez
|
Alexandre Gonzalvez
|
||||||
Théau Giraud
|
Théau Giraud
|
||||||
Léonie Gallois
|
Léonie Gallois
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*************Manuel d’installation & d’utilisation de l’application*************
|
|
||||||
|
|
||||||
Ce manuel est aussi disponible dans le rapport, notamment avec des images pour la partie utilisation. Nous vous conseillons aussi vivement de regarder la vidéo explicative se trouvant dans le même repository que ce fichier.
|
|
||||||
|
|
||||||
Etape 1: Télécharger le projet via GitEtud
|
|
||||||
|
|
||||||
Tout d’abord, allez sur le GitEtud de L’INSA Toulouse à cette adresse: https://git.etud.insa-toulouse.fr/gallois/Clavardage. Notre projet s’appelle Clavardage, vous pouvez effectuer un pull à partir de la branche master. (D’autres versions du projet sont également disponibles, par exemple la branche v1 ne nécessite aucune installation supplémentaire mais ne gère pas la récupération de l’historique).
|
|
||||||
|
|
||||||
Etape 2: Télécharger MySQL Workbench
|
|
||||||
|
|
||||||
Ensuite, pour faire le lien avec notre base de données, il vous faudra installer MySQL Workbench et ConnectorJ. MySQL est gratuit et répond bien à nos besoins pour la base de données. Voici un lien vers la page de téléchargement: https://dev.mysql.com/downloads/workbench/.
|
|
||||||
|
|
||||||
Vous remarquerez que la page web suivante vous demande un login. Il n’est pas obligatoire. Vous pouvez directement cliquer sur “No thanks, just start my download” en bas de la page et télécharger MySQL sans compte. Dans le setup MySQL il vous faudra télécharger seulement le Workbench et le ConnectorJ.
|
|
||||||
|
|
||||||
Il n’y a ensuite pas de manipulations à faire avec MySQL. La connexion avec la base de données a déjà été mise en place dans le code de l’application et du côté du serveur.
|
|
||||||
|
|
||||||
Etape 3: Connexion au VPN de L’INSA
|
|
||||||
|
|
||||||
Si vous utilisez une machine se situant à l’INSA vous pouvez passer cette étape. Sinon, il vous faudra vous connecter au réseau de l’INSA en utilisant un VPN pour faire marcher la base de données qui utilise ce réseau. Voici le lien vers la page du CSN expliquant sa mise en place: http://csn.insa-toulouse.fr/fr/services/services-transverses/connexion-par-vpn.html.
|
|
||||||
|
|
||||||
Etape 4: Lancement et utilisation de l’application
|
|
||||||
|
|
||||||
Vérifiez bien d’être connecté au VPN avant de tester l’application. Comme dans la vidéo explicative (que nous vous conseillons et qui est elle aussi sur le git), vous avez juste à ouvrir le fichier Client.jar dans le répertoire Executable ainsi qu’un ou plusieurs des .jar utilisateurs distants.
|
|
||||||
|
|
||||||
Quand vous ouvrez l’application, une fenêtre apparaît vous demandant votre Pseudo. Vous recevrez un message de confirmation avec votre Pseudo affiché ou un message d’erreur s’il n’est pas valide.
|
|
||||||
|
|
||||||
L’interface s’ouvrira ensuite. Vous pourrez changer votre Pseudo dans la barre de texte à côté de “Change nickname:”. Les mêmes messages de confirmation/d’erreur apparaîtront.
|
|
||||||
|
|
||||||
Ensuite, pour commencer un chat avec un des autres utilisateurs, cliquez sur la flèche du menu déroulant répertoriant leurs noms. Double-cliquez sur un utilisateur et un message de confirmation s’ouvrira.
|
|
||||||
|
|
||||||
Une fenêtre de chat vide s’ouvre. Vous pouvez y taper vos messages et les envoyer.
|
|
||||||
|
|
||||||
Pour visualiser l’arrivée des messages, établissez la connexion en faisant la même manip sur l’interface de l’utilisateur distant avec lequel vous communiquez. Vous verrez ici qu’un chat existant déjà, une fenêtre s’ouvre en disant que l’on va chercher les messages envoyés qui ont été stockés dans la base de données.
|
|
||||||
|
|
||||||
Les messages envoyés sont récupérés et sont affichés dans la fenêtre chat de l’utilisateur distant. Vous pouvez aussi changer encore une fois les pseudos et voir que les messages envoyés après le changement de pseudo sont marqués avec celui-ci.
|
|
||||||
|
|
||||||
Pour fermer le chat, cliquez sur le bouton “Close session”.
|
|
||||||
|
|
||||||
Vous pouvez aussi fermer les applications entièrement en cliquant sur la croix rouge en haut à droite. En rouvrant une nouvelle instance de l’application, vous pouvez (notamment avec un pseudo différent si cela vous chante, votre adresse sera quand même reconnue) relancer un chat avec l’utilisateur précédent. Les messages ayant été stockés dans la base de données, ils seront récupérés et affichés tels qu'ils avaient été envoyés.
|
|
||||||
|
|
||||||
*************Fin du manuel d’installation & d’utilisation de l’application*************
|
|
||||||
|
|
BIN
Rapport COO.pdf
BIN
Rapport COO.pdf
Binary file not shown.
BIN
Rapport POO.pdf
BIN
Rapport POO.pdf
Binary file not shown.
12
RemoteSystemsTempFiles/.project
Normal file
12
RemoteSystemsTempFiles/.project
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>RemoteSystemsTempFiles</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
34
Server.java
34
Server.java
|
@ -1,34 +0,0 @@
|
||||||
package websocket;
|
|
||||||
|
|
||||||
import javax.websocket.server.*;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import javax.websocket.*;
|
|
||||||
|
|
||||||
@ServerEndpoint("/hello/")
|
|
||||||
public class Server {
|
|
||||||
private Session session;
|
|
||||||
|
|
||||||
@OnOpen
|
|
||||||
public void connect(Session session) {
|
|
||||||
this.session= session;
|
|
||||||
System.out.println("session :"+ session);
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnClose
|
|
||||||
public void close() {
|
|
||||||
this.session=null;
|
|
||||||
System.out.println("session closed");
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnMessage
|
|
||||||
public void onMessage(String msg) throws IOException {
|
|
||||||
System.out.println("msg recu:"+msg);
|
|
||||||
this.session.getAsyncRemote().sendText("server:"+msg);
|
|
||||||
//if (this.session != null && this.session.isOpen()) {
|
|
||||||
// this.session.getBasicRemote().sendText("server:"+msg);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
BIN
Statechart_Diagram.jpg
Normal file
BIN
Statechart_Diagram.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
Loading…
Reference in a new issue