@@ -13,16 +13,23 @@ Running the Example
13
13
14
14
There's a simple chat server and client example located in the ` example `
15
15
folder. First, compile the example classes and JAR file:
16
- ant
16
+
17
+ ``` shell
18
+ ant
19
+ ```
17
20
18
21
Then, start the chat server (a ` WebSocketServer ` subclass):
19
22
20
- java -cp example:dist/WebSocket.jar ChatServer
23
+ ``` shell
24
+ java -cp example:dist/WebSocket.jar ChatServer
25
+ ```
21
26
22
27
Now that the server is started, we need to connect some clients. Run the
23
28
Java chat client (a ` WebSocketClient ` subclass):
24
29
25
- java -cp example:dist/WebSocket.jar ChatClient
30
+ ``` shell
31
+ java -cp example:dist/WebSocket.jar ChatClient
32
+ ```
26
33
27
34
The chat client is a simple Swing GUI application that allows you to send
28
35
messages to all other connected clients, and receive messages from others in a
@@ -57,20 +64,25 @@ Testing in Android Emulator
57
64
Please note Android Emulator has issues using ` IPv6 addresses ` . Executing any
58
65
socket related code (like this library) inside it will address an error
59
66
60
- java.net.SocketException: Bad address family
67
+ ``` shell
68
+ java.net.SocketException: Bad address family
69
+ ```
61
70
62
71
You have to manually disable ` IPv6 ` by calling
63
-
64
- java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
65
- java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
72
+
73
+ ``` java
74
+ java.lang. System . setProperty(" java.net.preferIPv6Addresses" , " false" );
75
+ java.lang. System . setProperty(" java.net.preferIPv4Stack" , " true" );
76
+ ```
66
77
67
78
somewhere in your project, before instantiating the ` WebSocketClient ` class.
68
79
You can check if you are currently testing in the Android Emulator like this
69
-
70
- if ("google_sdk".equals( Build.PRODUCT ))
71
- {
72
- ... disable IPv6
73
- }
80
+
81
+ ``` java
82
+ if (" google_sdk" . equals( Build . PRODUCT )) {
83
+ // ... disable IPv6
84
+ }
85
+ ```
74
86
75
87
76
88
License
0 commit comments