Skip to content

Commit 7b9df90

Browse files
committed
Updated README.md
1 parent b697296 commit 7b9df90

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

README.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# WebSocket for Android [![GitHub version](https://badge.fury.io/gh/knowledgecode%2FWebSocket-for-Android.svg)](http://badge.fury.io/gh/knowledgecode%2FWebSocket-for-Android)
2-
WebSocket for Android is a Cordova plugin that allows WebSockets (RFC 6455) to be used on Android.
2+
WebSocket for Android is a Cordova plugin that makes WebSocket (RFC 6455) available on Android.
33
This is based on [Jetty 8](https://github.com/eclipse/jetty.project/tree/jetty-8) under the terms of the Apache License v2.0.
44

55
## Requirements
66
- Android 2.3 or later (recommended 4.1 or later)
77
- `cordova-android@3.0.0` or later or compatible framework
8-
- `cordova-plugin-whitelist` or `cordova-plugin-legacy-whitelist` if using `cordova-android@4.0.0` or later
8+
- `cordova-plugin-whitelist` or `cordova-plugin-legacy-whitelist` if using `cordova-android@4.0.0` and later
99

1010
The plugin for Cordova 2.x can be found [here](https://github.com/knowledgecode/WebSocket-for-Android/tree/2.x).
1111

@@ -24,21 +24,21 @@ The plugin for Cordova 2.x can be found [here](https://github.com/knowledgecode/
2424

2525
#### Notes
2626
- WSS protocol is only supported TLS. SSLv3 is not.
27-
- Android 3.x (Honeycomb) are not supported (maybe work, but not tested).
28-
- A new WebView based on Chromium supports WebSockets. Specifically Android 4.4 (KitKat) and later support them, so this plugin is **NOT** used on them by default.
29-
- This plugin can be used [Crosswalk](https://crosswalk-project.org/) together in `cordova-android@4.0.0`. In this case also this is not used by default because it supports WebSockets.
30-
- If include Android 5.x (Lollipop) as target, would be better to build with `cordova-android@3.7.1` or later.
27+
- Android 3.x (Honeycomb) are not supported (might work but is not tested).
28+
- A new WebView based on Chromium supports WebSocket. Specifically Android 4.4 (KitKat) and later support them, so this plugin is **NOT** used on them by default.
29+
- In `cordova-android@4.0.0` and later, this plugin can be used together with [Crosswalk](https://crosswalk-project.org/). In this case also it is not used by default because Crosswalk supports WebSocket.
30+
- To support Android 5.x (Lollipop), would be better to build with `cordova-android@3.7.1` or later.
3131

3232
## Installation
3333
Use Cordova Command-Line Interface (CLI). At first, check Cordova version:
3434
```sh
3535
$ cordova --version
3636
```
37-
If using 5.0.0 or later:
37+
If using 5.0.0 or later (via npm):
3838
```sh
3939
$ cordova plugin add cordova-plugin-websocket
4040
```
41-
If using other old versions:
41+
If using other old versions (via GitHub):
4242
```sh
4343
$ cordova plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
4444
```
@@ -70,7 +70,7 @@ Remove and reinstall:
7070
$ cordova plugin rm <PLUGIN ID>
7171
$ cordova plugin add cordova-plugin-websocket
7272
```
73-
Also will need to install `cordova-plugin-whitelist` or `cordova-plugin-legacy-whitelist` if using `cordova-android@4.0.0`.
73+
Also will need to install `cordova-plugin-whitelist` or `cordova-plugin-legacy-whitelist` if using `cordova-android@4.0.0` and later.
7474

7575
#### Caveats
7676
When install this plugin, it adds `INTERNET` permission to `platforms/android/AndroidManifest.xml`. If remove this plugin, the permission is also removed at the same time even if it is required for other plugins.
@@ -103,29 +103,32 @@ document.addEventListener('deviceready', function () {
103103
}, false);
104104
```
105105
#### Options
106-
This plugin has the following options. All these parameters are optional. Of course these don't affect native WebSocket.
107-
108-
| key | default value | supported version |
109-
|:---------------------|:---------------------|:-------------------------|
110-
| origin | file:// (usually) | v0.3.0 ~ |
111-
| maxConnectTime | 75000 | v0.4.0 ~ |
112-
| maxTextMessageSize | -1 | v0.4.0 ~ (except v0.8.x) |
113-
| maxBinaryMessageSize | -1 | v0.4.0 ~ (except v0.8.x) |
114-
| override | false | v0.8.0 ~ |
115-
| agent | (depends on devices) | v0.9.0 ~ |
116-
117-
`origin` is a value to set the request header field. Default value is usually `file://`. This is the same value as when using native WebSocket.
106+
This plugin has the following options. All these parameters are optional. Of course these don't affect built-in WebSocket.
107+
108+
| key | type | default value | supported version |
109+
|:---------------------|:--------|:--------------------|:-------------------------|
110+
| origin | String | file:// (usually) | v0.3.0 ~ |
111+
| maxConnectTime | Number | 75000 | v0.4.0 ~ |
112+
| maxTextMessageSize | Number | -1 | v0.4.0 ~ (except v0.8.x) |
113+
| maxBinaryMessageSize | Number | -1 | v0.4.0 ~ (except v0.8.x) |
114+
| override | Boolean | false | v0.8.0 ~ |
115+
| agent | String | (depends on device) | v0.9.0 ~ |
116+
| perMessageDeflate | Boolean | false | v0.10.0 ~ |
117+
118+
`origin` is a value to set the request header field. Default value is usually `file://`. This is the same value as when using built-in WebSocket.
118119
`maxConnectTime` is time to wait for connection. A unit is millisecond.
119-
`maxTextMessageSize` and `maxBinaryMessageSize` are receivable maximum size from a server. Default value is -1 (unlimited. depends on heap size of devices). A unit is byte.
120-
`override` is a flag to force WebView to use this plugin even if supports WebSockets. For example, in case that want to apply them these options. However will be slower than native WebSocket.
121-
`agent` is user-agent to set the request header field. Default value depends on devices. This is the same value as when using native WebSocket.
120+
`maxTextMessageSize` and `maxBinaryMessageSize` are receivable maximum size from the server. Default value is -1 (unlimited. depends on devices heap size). A unit is byte.
121+
`override` is a flag to force WebView to use this plugin even if it supports WebSocket. However in most cases it will be slower than built-in WebSocket.
122+
`agent` is user-agent to set the request header field. Default value depends on devices. This is the same value as when using built-in WebSocket.
123+
`perMessageDeflate` is a flag whether to use permessage-deflate extension or not. Default value is false for now because it is still experimental. If you would like to try it, set to true. However It is necessary that the server supports permessage-deflate.
122124

123125
If change these parameters, need to do before creating a instance:
124126
```javascript
125127
WebSocket.pluginOptions = {
126128
origin: 'http://example.com',
127129
maxConnectTime: 5000,
128-
override: true
130+
override: true,
131+
perMessageDeflate: true
129132
};
130133

131134
var ws = new WebSocket('ws://echo.websocket.org');

0 commit comments

Comments
 (0)