websocket

This commit is contained in:
LMAGallois 2021-02-13 13:29:22 +01:00
parent 72d6f53020
commit 94031cc356
16 changed files with 26 additions and 45 deletions

View file

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="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"/>
</classpath>

View file

@ -1,3 +1,2 @@
/websocket/
/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.

View file

@ -8,6 +8,7 @@ import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.sql.SQLException;
import java.text.DateFormat;
@ -17,6 +18,7 @@ import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.websocket.DeploymentException;
import model.Chat;
import model.LocalUser;
@ -24,6 +26,7 @@ import model.Message;
import model.Msg_Text;
import model.RemoteUser;
import view.Interface;
import websocket.Appel;
public class Controller {
@ -508,6 +511,8 @@ public class Controller {
Controller ctr = new Controller(31014,portUDPlistening_local,31024,histoire);
lstCtr.add(ctr);
Appel app=new Appel();
app.test();
/** Loop **/
Boolean running = isRunning(lstCtr);

View file

@ -16,13 +16,18 @@ public class Appel {
private Client client;
public void test() {
this.container= ContainerProvider.getWebSocketContainer();
this.client=new Client();
Session session=null;
try {
Session session=this.container.connectToServer(this.client, new URI ("ws://localhost:8080/Clavardage/hello"));
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");
@ -30,10 +35,5 @@ public class Appel {
}
}
public void onInit(){
this.container= ContainerProvider.getWebSocketContainer();
this.client=new Client();
}
}

View file

@ -0,0 +1,5 @@
package websocket;
public class Centralized {
}

View file

@ -1,36 +0,0 @@
package websocket;
import static org.junit.jupiter.api.Assertions.fail;
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;
import org.junit.Before;
class Test {
@org.junit.jupiter.api.Test
void test() throws IOException, DeploymentException, URISyntaxException {
Session session=this.container.connectToServer(this.client, new URI ("ws://localhost:8080/Clavardage/hello"));
this.client.sendMessage("hello from client");
}
private WebSocketContainer container;
private Client client;
@Before
public void onInit(){
this.container= ContainerProvider.getWebSocketContainer();
this.client=new Client();
}
}