File tree 2 files changed +30
-4
lines changed
main/java/org/javaee7/websocket/binary
test/java/org/javaee7/websocket/binary/test
2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ *
3
+ */
4
+ package org .javaee7 .websocket .binary ;
5
+
6
+ import java .io .IOException ;
7
+ import java .nio .ByteBuffer ;
8
+
9
+ import javax .websocket .ClientEndpoint ;
10
+ import javax .websocket .OnOpen ;
11
+ import javax .websocket .Session ;
12
+
13
+ /**
14
+ * @author Nikolaos Ballas
15
+ *
16
+ */
17
+ @ ClientEndpoint
18
+ public class MyEndpointClient {
19
+ @ OnOpen
20
+ public void onOpen (Session session ){
21
+ System .out .println ("[Action]->Invokint method onOpen of the class:" +this .getClass ().getCanonicalName ());
22
+ try {
23
+ session .getBasicRemote ().sendBinary (ByteBuffer .wrap ("Hello World!" .getBytes ()));
24
+ }catch (IOException ioe ){
25
+ ioe .printStackTrace ();
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change 7
7
import java .io .IOException ;
8
8
import java .net .URI ;
9
9
import java .net .URISyntaxException ;
10
- import java .nio .ByteBuffer ;
11
10
12
11
import javax .websocket .ContainerProvider ;
13
12
import javax .websocket .DeploymentException ;
14
- import javax .websocket .Session ;
15
13
import javax .websocket .WebSocketContainer ;
16
14
17
15
import org .javaee7 .websocket .binary .MyEndpoint ;
16
+ import org .javaee7 .websocket .binary .MyEndpointClient ;
18
17
import org .jboss .arquillian .container .test .api .Deployment ;
19
18
import org .jboss .arquillian .container .test .api .TargetsContainer ;
20
19
import org .jboss .arquillian .junit .Arquillian ;
@@ -53,7 +52,6 @@ public static WebArchive createDeployment(){
53
52
@ Test
54
53
public void testEndPointBinary () throws URISyntaxException , DeploymentException ,IOException {
55
54
WebSocketContainer socketContainer = ContainerProvider .getWebSocketContainer ();
56
- Session session = socketContainer .connectToServer (MyEndpoint .class , new URI ("ws://localhost:8080/binary/websockeet" ));
57
- session .getBasicRemote ().sendBinary (ByteBuffer .wrap ("Hello World" .getBytes ()));
55
+ socketContainer .connectToServer (MyEndpointClient .class , new URI ("ws://localhost:8080/binary/websockeet" ));
58
56
}
59
57
}
You can’t perform that action at this time.
0 commit comments