source: src/test/java/geniusweb/examples/MyClientEndpoint.java@ 44

Last change on this file since 44 was 43, checked in by ruud, 21 months ago

Fixed small issues in domaineditor.

File size: 903 bytes
RevLine 
[43]1package geniusweb.examples;
2
3import java.io.IOException;
4
5import javax.websocket.ClientEndpoint;
6import javax.websocket.OnError;
7import javax.websocket.OnMessage;
8import javax.websocket.OnOpen;
9import javax.websocket.Session;
10
11@ClientEndpoint
12public class MyClientEndpoint {
13 String received = "";
14
15 public MyClientEndpoint() {
16 }
17
18 @OnOpen
19 public void onOpen(Session session) {
20 System.out.println("Connected to endpoint: " + session);
21 String name = "Duke";
22 System.out.println("Sending message to endpoint: " + name);
23 try {
24 session.getBasicRemote().sendText(name);
25 } catch (IOException e) {
26 // TODO Auto-generated catch block
27 e.printStackTrace();
28 }
29 }
30
31 @OnMessage
32 public void processMessage(String message) {
33 System.out.println("Received message in client: " + message);
34 received = message;
35 }
36
37 @OnError
38 public void processError(Throwable t) {
39 t.printStackTrace();
40 }
41
42}
Note: See TracBrowser for help on using the repository browser.