Last change
on this file since 32 was 32, checked in by bart, 3 years ago |
LEARN algorithm now also available. Fixed small issues.
|
File size:
903 bytes
|
Line | |
---|
1 | package geniusweb.examples;
|
---|
2 |
|
---|
3 | import java.io.IOException;
|
---|
4 |
|
---|
5 | import javax.websocket.ClientEndpoint;
|
---|
6 | import javax.websocket.OnError;
|
---|
7 | import javax.websocket.OnMessage;
|
---|
8 | import javax.websocket.OnOpen;
|
---|
9 | import javax.websocket.Session;
|
---|
10 |
|
---|
11 | @ClientEndpoint
|
---|
12 | public 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.