Skip to content

Commit 0bbe1d2

Browse files
committed
Merge branch 'develop'
2 parents 159bea7 + 2f819ac commit 0bbe1d2

File tree

97 files changed

+169
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+169
-149
lines changed

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
==============================================================
22
Jetty Web Container
3-
Copyright 1995-2014 Mort Bay Consulting Pty Ltd.
3+
Copyright 1995-2015 Mort Bay Consulting Pty Ltd.
44
==============================================================
55

66
The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd

README.md

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# WebSocket for Android
2-
WebSocket for Android is a Cordova/PhoneGap plugin that allows WebSockets (RFC 6455) to be used on Android.
2+
WebSocket for Android is a Cordova plugin that allows WebSockets (RFC 6455) to be used on Android.
33
This is using [Jetty 8](https://github.com/eclipse/jetty.project/tree/jetty-8) under the terms of the Apache License v2.0.
44

55
## Requirements
6-
- Java 1.6 or higher
7-
- Android 2.2 or higher (recommended 4.0 or higher)
8-
- Cordova/PhoneGap 3.0.0 or higher
6+
- Android 2.2 or later (recommended 4.1 or later)
7+
- Apache Cordova Android 3.0.0 or later or compatible framework
98

10-
The version for Cordova/Phonegap 2.x, [see here](https://github.com/knowledgecode/WebSocket-for-Android/tree/2.x).
9+
The plugin for Cordova 2.x, [see here](https://github.com/knowledgecode/WebSocket-for-Android/tree/2.x).
1110

1211
## Supported Features
1312
| version | WS protocol | WSS protocol | text message | binary message |
@@ -19,46 +18,58 @@ The version for Cordova/Phonegap 2.x, [see here](https://github.com/knowledgecod
1918
| 4.1.2 (API 16) |||||
2019
| 4.2.2 (API 17) |||||
2120
| 4.3.1 (API 18) |||||
22-
| 4.4.2 (API 19) |||||
21+
| 4.4.2 (API 19) | - | - | - | - |
22+
| 5.0.1 (API 21) | - | - | - | - |
2323

2424
#### Notes
25-
- The WSS protocol is now available on 2.3 or higher (SSLv3 is not supported. TLS only.).
25+
- The WSS protocol is now available on 2.3 or later (SSLv3 is not supported. TLS only.).
2626
- 3.x devices are not supported (maybe work, but not tested).
27-
- The WebView has officially supported WebSockets since 4.4 (KitKat). Therefore this plugin is not used on those devices by default.
27+
- The WebView has officially supported WebSockets since Android 4.4. Therefore this plugin is **NOT** used on them by default.
28+
- If target Android 5.0, would be better to build with Cordova Android 3.7.1 or later.
2829

2930
## Installing
30-
Use the Cordova/PhoneGap Command-Line interface:
31-
```shell
32-
$ cordova plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
31+
Use Cordova Command-Line Interface (CLI) :
32+
```sh
33+
$ cordova plugin add com.knowledgecode.cordova.websocket
3334
```
3435
or
35-
```shell
36-
$ phonegap plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
36+
```sh
37+
$ cordova plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
38+
```
39+
If you are developing the iOS version in parallel, this plugin will be also installed there:
40+
```sh
41+
$ cordova plugin add com.knowledgecode.cordova.websocket
42+
Fetching plugin "com.knowledgecode.cordova.websocket" via plugin registry
43+
Installing "com.knowledgecode.cordova.websocket" for android
44+
Installing "com.knowledgecode.cordova.websocket" for ios
3745
```
38-
This plugin is for Android. However if install this via the CLI, it also affects all other platforms (such as iOS). This is a specification.
39-
In fact, it writes only an installation history in those platforms. (There are no tangible ill effects.)
40-
If you mind this thing, recommended to use Cordova Plugman that can specify an installation platform. Execute this on a project root:
41-
```shell
42-
$ plugman install --platform android --project platforms/android --plugin https://github.com/knowledgecode/WebSocket-for-Android.git --plugins_dir plugins
46+
This is a feature of CLI. There are no tangible ill effects. If you want to avoid this thing, use Cordova Plugman:
47+
48+
```sh
49+
$ plugman install --platform android --project ./platforms/android --plugins_dir ./plugins --plugin com.knowledgecode.cordova.websocket
50+
Fetching plugin "com.knowledgecode.cordova.websocket" via plugin registry
51+
npm http GET http://registry.cordova.io/com.knowledgecode.cordova.websocket
52+
npm http 200 http://registry.cordova.io/com.knowledgecode.cordova.websocket
53+
Installing "com.knowledgecode.cordova.websocket" for android
4354
```
4455
### Upgrading from previous versions
45-
Just remove and reinstall.
46-
```shell
56+
Just remove and reinstall:
57+
```sh
4758
$ cordova plugin remove com.knowledgecode.cordova.websocket
48-
$ cordova plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
59+
$ cordova plugin add com.knowledgecode.cordova.websocket
4960
```
5061
or
51-
```shell
52-
$ phonegap plugin remove com.knowledgecode.cordova.websocket
53-
$ phonegap plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
62+
```sh
63+
$ cordova plugin remove com.knowledgecode.cordova.websocket
64+
$ cordova plugin add https://github.com/knowledgecode/WebSocket-for-Android.git
5465
```
55-
in the case of Plugman:
56-
```shell
57-
$ plugman uninstall --platform android --project platforms/android --plugin com.knowledgecode.cordova.websocket --plugins_dir plugins
58-
$ plugman install --platform android --project platforms/android --plugin https://github.com/knowledgecode/WebSocket-for-Android.git --plugins_dir plugins
66+
or
67+
```sh
68+
$ plugman uninstall --platform android --project ./platforms/android --plugins_dir ./plugins --plugin com.knowledgecode.cordova.websocket
69+
$ plugman install --platform android --project ./platforms/android --plugins_dir ./plugins --plugin com.knowledgecode.cordova.websocket
5970
```
6071
#### BUILD FAILED ?
61-
Try to delete all files (cache) in platforms/android/ant-build/.
72+
Delete all files in ./platforms/android/ant-build/. These are cache.
6273

6374
#### Caution
6475
When install this plugin, it adds `INTERNET` permission to `AndroidManifest.xml`. If remove this plugin, the permission is also removed at the same time even if it is required for other plugins.
@@ -67,7 +78,7 @@ When install this plugin, it adds `INTERNET` permission to `AndroidManifest.xml`
6778
### *WebSocket(url[, protocols])*
6879
The WebSocket(url, protocols) constructor takes one or two arguments. The first argument, url, specifies the URL to which to connect. The second, protocols, is either a string or an array of strings.
6980
A simple code is as follows:
70-
```JavaScript
81+
```javascript
7182
document.addEventListener('deviceready', function () {
7283
var ws = new WebSocket('ws://echo.websocket.org');
7384

@@ -91,19 +102,18 @@ document.addEventListener('deviceready', function () {
91102
}, false);
92103
```
93104
#### Options
94-
This plugin has the following options. All these parameters are omissible. Of course these don't affect the native WebSocket.
95-
96-
| key | default value | remarks |
97-
|:---------------------|:-------------:|:-------------|
98-
| origin | (empty) | |
99-
| maxConnectTime | 75000 | |
100-
| override | false | since v0.8.0 |
101-
102-
The `origin` is a value to set the request header field.
103-
The `maxConnectTime` is time to wait for connection. The default value will be 75,000 milliseconds if omit it.
104-
The `override` is a flag to override the native WebSocket on 4.4 or higher devices. The default value will be false if omit it. Set to true if you want to enable the plugin WebSocket even though those support WebSockets.
105-
If you want to change these parameters, need to do before creating a instance:
106-
```JavaScript
105+
This plugin has the following options. All these parameters are optional. Of course these don't affect the native WebSocket.
106+
107+
| key | default value |
108+
|:---------------------|:-------------:|
109+
| origin | (empty) |
110+
| maxConnectTime | 75000 |
111+
| override | false |
112+
113+
`origin` is a value to set the request header field. `maxConnectTime` is time to wait for connection. `override` is a flag to override the native WebSocket on Android 4.4 or later devices. Set to true if want to force them to use the plugin. In most cases, it is slower than the native WebSocket.
114+
115+
If want to change these parameters, need to do before creating a instance:
116+
```javascript
107117
WebSocket.pluginOptions = {
108118
origin: 'http://example.com',
109119
maxConnectTime: 5000,
@@ -116,18 +126,22 @@ var ws = new WebSocket('ws://echo.websocket.org');
116126
Transmits data to the server over the WebSocket connection. The data takes a string, a blob, or an arraybuffer.
117127

118128
#### Notes
119-
The size of messages that can transmit and receive at a time depends on the heap memory on devices. You would be better to consider a way to split messages if those are large (hundreds of kilobytes).
129+
The size of message that can transmit and receive at a time depends on heap size. Would be better to consider a way to split a message if it is quite large.
120130

121131
### *close([code[, reason]])*
122132
Closes the WebSocket connection or connection attempt, if any.
123133

124134
## Change Log
135+
#### 0.8.1
136+
* fixed frame aggregation error (thanks to @Atsyn)
137+
* fixed binary transmission for the case of using the plugin on 4.4 or later
138+
125139
#### 0.8.0
126140
* performance tuning (about 5% to 15% faster than previous versions)
127141
* deployed the sources of Jetty directly (instead the jar file)
128142
* abolished the maxTextMessageSize/maxBinaryMessageSize options
129143
* added the "override" option
130-
* refactoring
144+
* refactor
131145

132146
#### 0.7.0
133147
* resolved the issue of SSL on 4.0 and 2.3 (thanks to @agalazis and koush/AndroidAsync)

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
id="com.knowledgecode.cordova.websocket"
6-
version="0.8.0">
6+
version="0.8.1">
77
<name>WebSocket for Android</name>
88
<description>Cordova WebSocket Plugin for Android</description>
99
<license>Apache 2.0</license>

src/android/com/knowledgecode/cordova/websocket/ConnectionTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void execute(JSONArray args, CallbackContext ctx) {
122122
if (origin.length() > 0) {
123123
client.setOrigin(origin);
124124
}
125-
client.setMaxTextMessageSize(-1);
125+
client.setMaxTextMessageSize(Integer.MAX_VALUE);
126126
client.setMaxBinaryMessageSize(-1);
127127

128128
setCookie(client.getCookies(), uri.getHost());

src/android/org/eclipse/jetty/http/HttpCookie.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ========================================================================
3-
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3+
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
44
// ------------------------------------------------------------------------
55
// All rights reserved. This program and the accompanying materials
66
// are made available under the terms of the Eclipse Public License v1.0

src/android/org/eclipse/jetty/http/HttpException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ========================================================================
3-
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3+
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
44
// ------------------------------------------------------------------------
55
// All rights reserved. This program and the accompanying materials
66
// are made available under the terms of the Eclipse Public License v1.0

src/android/org/eclipse/jetty/http/HttpFields.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ========================================================================
3-
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3+
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
44
// ------------------------------------------------------------------------
55
// All rights reserved. This program and the accompanying materials
66
// are made available under the terms of the Eclipse Public License v1.0

src/android/org/eclipse/jetty/http/HttpHeaderValues.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ========================================================================
3-
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3+
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
44
// ------------------------------------------------------------------------
55
// All rights reserved. This program and the accompanying materials
66
// are made available under the terms of the Eclipse Public License v1.0

src/android/org/eclipse/jetty/http/HttpHeaders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ========================================================================
3-
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3+
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
44
// ------------------------------------------------------------------------
55
// All rights reserved. This program and the accompanying materials
66
// are made available under the terms of the Eclipse Public License v1.0

src/android/org/eclipse/jetty/http/HttpMethods.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ========================================================================
3-
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3+
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
44
// ------------------------------------------------------------------------
55
// All rights reserved. This program and the accompanying materials
66
// are made available under the terms of the Eclipse Public License v1.0

0 commit comments

Comments
 (0)