Browse Source

websocket

LMAGallois 3 years ago
parent
commit
94031cc356

+ 9
- 1
Application/Clavardage/.classpath View File

@@ -1,6 +1,14 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <classpath>
3
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
3
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
4
+		<attributes>
5
+			<attribute name="module" value="true"/>
6
+		</attributes>
7
+	</classpathentry>
4 8
 	<classpathentry kind="src" path="src"/>
9
+	<classpathentry kind="lib" path="C:/Program Files (x86)/MySQL/Connector J 8.0/mysql-connector-java-8.0.22.jar"/>
10
+	<classpathentry kind="lib" path="C:/Program Files/tyrus-standalone-client-1.9.jar"/>
11
+	<classpathentry kind="lib" path="C:/Program Files/javax.websocket-client-api-1.1.jar"/>
12
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
5 13
 	<classpathentry kind="output" path="bin"/>
6 14
 </classpath>

+ 1
- 2
Application/Clavardage/bin/.gitignore View File

@@ -1,3 +1,2 @@
1
+/websocket/
1 2
 /controller/
2
-/model/
3
-/view/

BIN
Application/Clavardage/bin/model/Chat.class View File


BIN
Application/Clavardage/bin/model/LocalUser.class View File


BIN
Application/Clavardage/bin/model/Message.class View File


BIN
Application/Clavardage/bin/model/Msg_Text.class View File


BIN
Application/Clavardage/bin/model/RemoteUser.class View File


BIN
Application/Clavardage/bin/model/User.class View File


BIN
Application/Clavardage/bin/view/Interface$1.class View File


BIN
Application/Clavardage/bin/view/Interface$2.class View File


BIN
Application/Clavardage/bin/view/Interface$3.class View File


BIN
Application/Clavardage/bin/view/Interface.class View File


+ 5
- 0
Application/Clavardage/src/controller/Controller.java View File

@@ -8,6 +8,7 @@ import java.net.DatagramPacket;
8 8
 import java.net.DatagramSocket;
9 9
 import java.net.InetAddress;
10 10
 import java.net.Socket;
11
+import java.net.URISyntaxException;
11 12
 import java.net.UnknownHostException;
12 13
 import java.sql.SQLException;
13 14
 import java.text.DateFormat;
@@ -17,6 +18,7 @@ import java.util.Calendar;
17 18
 import java.util.Date;
18 19
 
19 20
 import javax.swing.JOptionPane;
21
+import javax.websocket.DeploymentException;
20 22
 
21 23
 import model.Chat;
22 24
 import model.LocalUser;
@@ -24,6 +26,7 @@ import model.Message;
24 26
 import model.Msg_Text;
25 27
 import model.RemoteUser;
26 28
 import view.Interface;
29
+import websocket.Appel;
27 30
 
28 31
 public class Controller {
29 32
 
@@ -508,6 +511,8 @@ public class Controller {
508 511
 		Controller ctr = new Controller(31014,portUDPlistening_local,31024,histoire); 
509 512
 		lstCtr.add(ctr);
510 513
 		
514
+		Appel app=new Appel();
515
+		app.test();
511 516
 		
512 517
 		/** Loop **/
513 518
 		Boolean running = isRunning(lstCtr);

+ 6
- 6
Application/Clavardage/src/websocket/Appel.java View File

@@ -16,13 +16,18 @@ public class Appel {
16 16
 	private Client client; 
17 17
 	
18 18
 	public void test() {
19
+		this.container= ContainerProvider.getWebSocketContainer();
20
+		this.client=new Client();
21
+		
22
+		Session session=null;
19 23
 		try {
20
-			Session session=this.container.connectToServer(this.client, new URI ("ws://localhost:8080/Clavardage/hello"));
24
+			session=this.container.connectToServer(this.client, new URI ("ws://localhost:8082/WebSocket2/hello"));
21 25
 		} catch (DeploymentException | IOException | URISyntaxException e) {
22 26
 			e.printStackTrace();
23 27
 			System.out.println("pb avec le connect");
24 28
 		}
25 29
 		try {
30
+			this.client.onOpen(session, null);
26 31
 			this.client.sendMessage("hello from client");
27 32
 		} catch (IOException e) {
28 33
 			System.out.println("pb avec le sendMessage");
@@ -30,10 +35,5 @@ public class Appel {
30 35
 		}	
31 36
 	}
32 37
 	
33
-	
34 38
 
35
-	public void onInit(){
36
-	this.container= ContainerProvider.getWebSocketContainer();
37
-	this.client=new Client();
38
-	}
39 39
 }

+ 5
- 0
Application/Clavardage/src/websocket/Centralized.java View File

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

+ 0
- 36
Application/Clavardage/src/websocket/Test.java View File

@@ -1,36 +0,0 @@
1
-package websocket;
2
-
3
-import static org.junit.jupiter.api.Assertions.fail;
4
-
5
-import java.io.IOException;
6
-import java.net.URI;
7
-import java.net.URISyntaxException;
8
-
9
-import javax.websocket.ContainerProvider;
10
-import javax.websocket.DeploymentException;
11
-import javax.websocket.Session;
12
-import javax.websocket.WebSocketContainer;
13
-
14
-import org.junit.Before;
15
-
16
-
17
-class Test {
18
-
19
-	@org.junit.jupiter.api.Test
20
-	void test() throws IOException, DeploymentException, URISyntaxException {
21
-		Session session=this.container.connectToServer(this.client, new URI ("ws://localhost:8080/Clavardage/hello"));
22
-		this.client.sendMessage("hello from client");	
23
-	}
24
-	
25
-	
26
-	private WebSocketContainer container; 
27
-	private Client client;
28
-	@Before
29
-	public void onInit(){
30
-	this.container= ContainerProvider.getWebSocketContainer();
31
-	this.client=new Client();
32
-	}
33
-	
34
-	
35
-
36
-}

Loading…
Cancel
Save