File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
main/java/org/javaee7/websocket/binary
test/java/org/javaee7/websocket/binary/test Expand file tree Collapse file tree 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 77import java .io .IOException ;
88import java .net .URI ;
99import java .net .URISyntaxException ;
10- import java .nio .ByteBuffer ;
1110
1211import javax .websocket .ContainerProvider ;
1312import javax .websocket .DeploymentException ;
14- import javax .websocket .Session ;
1513import javax .websocket .WebSocketContainer ;
1614
1715import org .javaee7 .websocket .binary .MyEndpoint ;
16+ import org .javaee7 .websocket .binary .MyEndpointClient ;
1817import org .jboss .arquillian .container .test .api .Deployment ;
1918import org .jboss .arquillian .container .test .api .TargetsContainer ;
2019import org .jboss .arquillian .junit .Arquillian ;
@@ -53,7 +52,6 @@ public static WebArchive createDeployment(){
5352 @ Test
5453 public void testEndPointBinary () throws URISyntaxException , DeploymentException ,IOException {
5554 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" ));
5856 }
5957}
You can’t perform that action at this time.
0 commit comments