Skip to content

Commit cbd341c

Browse files
docs: update website
1 parent 2b5dfb9 commit cbd341c

File tree

6 files changed

+156
-52
lines changed

6 files changed

+156
-52
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
help: ## print this message
2+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
3+
4+
build-site: ## build the site
5+
mvn javadoc:javadoc site -DskipTests
6+
7+
.PHONY: build-site

README.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ See also: [Socket.IO-client Java](https://github.com/socketio/socket.io-client-j
2222
| -------------- | ---------------- | ---------------- |
2323
| 0.9.x | 1.x | 1.x |
2424
| 1.x | 3.x | 2.x |
25-
| - | 4.x | 3.x |
25+
| WIP | 4.x | 3.x |
2626

2727
## Installation
2828
The latest artifact is available on Maven Central.
@@ -132,43 +132,6 @@ socket = new Socket(opts);
132132
## Features
133133
This library supports all of the features the JS client does, including events, options and upgrading transport. Android is fully supported.
134134

135-
### Extra features only for Java client
136-
137-
#### Accessing HTTP Headers
138-
You can access HTTP headers like the following.
139-
140-
```java
141-
socket.on(Socket.EVENT_TRANSPORT, new Emitter.listener() {
142-
@Override
143-
public void call(Object... args) {
144-
// Called on a new transport created.
145-
Transport transport = (Transport)args[0];
146-
147-
transport.on(Transport.EVENT_REQUEST_HEADERS, new Emitter.Listener() {
148-
@Override
149-
public void call(Object... args) {
150-
@SuppressWarnings("unchecked")
151-
Map<String, List<String>> headers = (Map<String, List<String>>)args[0];
152-
// send cookie value to server.
153-
headers.put("Cookie", Arrays.asList("foo=1;"));
154-
}
155-
}).on(Transport.EVENT_RESPONSE_HEADERS, new Emitter.Listener() {
156-
@Override
157-
public void call(Object... args) {
158-
@SuppressWarnings("unchecked")
159-
Map<String, List<String>> headers = (Map<String, List<String>>)args[0];
160-
// receive cookie value from server.
161-
String cookie = headers.get("Set-Cookie").get(0);
162-
}
163-
});
164-
}
165-
});
166-
```
167-
168-
See the Javadoc for more details.
169-
170-
http://socketio.github.io/engine.io-client-java/apidocs/
171-
172135
## License
173136

174137
MIT

pom.xml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,9 @@
200200
<version>2.3</version>
201201
</plugin>
202202
<plugin>
203-
<groupId>com.github.github</groupId>
204-
<artifactId>site-maven-plugin</artifactId>
205-
<version>0.12</version>
206-
<configuration>
207-
<message>Creating site for ${project.version}</message>
208-
</configuration>
209-
<executions>
210-
<execution>
211-
<goals>
212-
<goal>site</goal>
213-
</goals>
214-
<phase>site</phase>
215-
</execution>
216-
</executions>
203+
<groupId>org.apache.maven.plugins</groupId>
204+
<artifactId>maven-site-plugin</artifactId>
205+
<version>3.9.1</version>
217206
</plugin>
218207
</plugins>
219208
</build>

src/site/markdown/installation.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Compatibility
2+
3+
| Client version | Engine.IO server | Socket.IO server |
4+
| -------------- | ---------------- | ---------------- |
5+
| 0.9.x | 1.x | 1.x |
6+
| 1.x | 3.x | 2.x |
7+
| WIP | 4.x | 3.x |
8+
9+
## Installation
10+
The latest artifact is available on Maven Central.
11+
12+
### Maven
13+
Add the following dependency to your `pom.xml`.
14+
15+
```xml
16+
<dependencies>
17+
<dependency>
18+
<groupId>io.socket</groupId>
19+
<artifactId>engine.io-client</artifactId>
20+
<version>1.0.1</version>
21+
</dependency>
22+
</dependencies>
23+
```
24+
25+
### Gradle
26+
Add it as a gradle dependency for Android Studio, in `build.gradle`:
27+
28+
```groovy
29+
compile ('io.socket:engine.io-client:1.0.1') {
30+
// excluding org.json which is provided by Android
31+
exclude group: 'org.json', module: 'json'
32+
}
33+
```

src/site/markdown/usage.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
## Usage
2+
Engine.IO-client Java has the similar api with the JS client. You can use `Socket` to connect:
3+
4+
```java
5+
socket = new Socket("ws://localhost");
6+
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
7+
@Override
8+
public void call(Object... args) {
9+
socket.send("hi");
10+
socket.close();
11+
}
12+
});
13+
socket.open();
14+
```
15+
16+
You can listen events as follows:
17+
18+
```java
19+
socket.on(Socket.EVENT_MESSAGE, new Emitter.Listener() {
20+
@Override
21+
public void call(Object... args) {
22+
String data = (String)args[0];
23+
}
24+
}).on(Socket.EVENT_ERROR, new Emitter.Listener() {
25+
@Override
26+
public void call(Object... args) {
27+
Exception err = (Exception)args[0];
28+
}
29+
});
30+
```
31+
32+
How to set options:
33+
34+
```java
35+
opts = new Socket.Options();
36+
opts.transports = new String[] {WebSocket.NAME};
37+
38+
socket = new Socket(opts);
39+
```
40+
41+
Sending and receiving binary data:
42+
43+
```java
44+
socket = new Socket();
45+
socket.on(Socket.EVENT_OPEN, new Emitter.Listener() {
46+
@Override
47+
public void call(Object... args) {
48+
// send binary data
49+
byte[] data = new byte[42];
50+
socket.send(data);
51+
}
52+
}).on(Socket.EVENT_MESSAGE, new Emitter.Listener() {
53+
@Override
54+
public void call(Object... args) {
55+
// receive binary data
56+
byte[] data = (byte[])args[0];
57+
}
58+
});
59+
```
60+
61+
Use custom SSL settings:
62+
63+
```java
64+
OkHttpClient okHttpClient = new OkHttpClient.Builder()
65+
.hostnameVerifier(myHostnameVerifier)
66+
.sslSocketFactory(mySSLContext.getSocketFactory(), myX509TrustManager)
67+
.build();
68+
69+
// default SSLContext for all sockets
70+
Socket.setDefaultOkHttpWebSocketFactory(okHttpClient);
71+
Socket.setDefaultOkHttpCallFactory(okHttpClient);
72+
73+
// set as an option
74+
opts = new Socket.Options();
75+
opts.callFactory = okHttpClient;
76+
opts.webSocketFactory = okHttpClient;
77+
socket = new Socket(opts);
78+
```
79+
80+
## Features
81+
82+
This library supports all of the features the JS client does, including events, options and upgrading transport. Android is fully supported.

src/site/site.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd">
4+
5+
<skin>
6+
<groupId>org.apache.maven.skins</groupId>
7+
<artifactId>maven-fluido-skin</artifactId>
8+
<version>1.9</version>
9+
</skin>
10+
11+
<custom>
12+
<fluidoSkin>
13+
<gitHub>
14+
<projectId>socketio/engine.io-client-java</projectId>
15+
<ribbonOrientation>right</ribbonOrientation>
16+
<ribbonColor>gray</ribbonColor>
17+
</gitHub>
18+
</fluidoSkin>
19+
</custom>
20+
21+
<body>
22+
<menu name="Overview">
23+
<item name="Installation" href="./installation.html"/>
24+
<item name="Usage" href="./usage.html"/>
25+
<item name="Javadoc" href="./apidocs/index.html"/>
26+
</menu>
27+
28+
<menu ref="reports"/>
29+
</body>
30+
</project>

0 commit comments

Comments
 (0)