Skip to content

Commit

Permalink
fix (uws): Update this to a fixed version and whole project to Node 8…
Browse files Browse the repository at this point in the history
…,10 (#47)

1) 'uws', due to some personal issues
(See: socketio/socket.io#3319), the author
has destroyed it since 10.148.2. And after several times of trying. Only
10.148.0 can work very very properly in both Nodejs 8.x and 10.x. So use
this instead (Solution from
facebook/react-native#17410).

2) Remove "please find another reliable library instead" in the
corresponding docs because we HAVE TO use 'uws', which is in the
engine.io library, it will check whether you are referring this lib or
not. If not, an error will be thrown out to you.
See:
https://github.com/socketio/engine.io/blob/6a16ea119280a02029618544d44eb515f7f2d076/lib/server.js#L107.

3) Upgrade the whole project to the latest version (Node 8, 10).
  • Loading branch information
Maledong authored and ngot committed Sep 20, 2018
1 parent 692cc6b commit 2e85c4a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language: node_js
node_js:
- '8'
- '9'
- '10'
install:
- npm i npminstall && npminstall
script:
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ exports.io = {

#### uws

**Note: `uws` isn't supported in Nodejs 10.x or later version by experiment, and it has been deprecated, please find another reliable library instead.**
**Egg's socket is using `ws`, [uws](https://www.npmjs.com/package/uws) is deprecated due to [some reasons](https://github.com/socketio/socket.io/issues/3319).**

If you insist using [uws](https://www.npmjs.com/package/uws) instead of the default `ws`, you can config like this:
If you insist using this, please config like this following:

```js
exports.io = {
init: { wsEngine: 'uws' },
};
```

read more about init config at: [engine.io](https://github.com/socketio/engine.io/blob/master/README.md#methods-1) .

see [config/config.default.js](config/config.default.js) for more detail.
- For more options in `init` : [engine.io](https://github.com/socketio/engine.io/blob/master/README.md#methods-1).
- For more configs of `Egg Socket` in default : [config.default.js](config/config.default.js).

### generateId

Expand Down
9 changes: 4 additions & 5 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ exports.io = {

#### uws

**注意:目前实测发现 `uws` 在 Nodejs 10.x 及其后续版本中不再被支持;且 `uws` 已经被官方弃用,请寻找其他可靠的替代库**
**Egg Socket 内部默认使用 `ws` 引擎,[uws](https://www.npmjs.com/package/uws) 因为[某些原因](https://github.com/socketio/socket.io/issues/3319)被废止**

如坚持使用 [uws](https://www.npmjs.com/package/uws) 替换掉默认的 `ws` , 可以这样配置:
如坚持需要使用,请按照以下配置即可:

```js
exports.io = {
init: { wsEngine: 'uws' },
};
```

更多 init 配置参考: [engine.io](https://github.com/socketio/engine.io/blob/master/README.md#methods-1) .

see [config/config.default.js](config/config.default.js) for more detail.
- 有关更多 `init` 选项配置,请参考:[engine.io](https://github.com/socketio/engine.io/blob/master/README.md#methods-1)
- 有关更多 `Egg Socket` 相关默认配置,请参考:[config.default.js](config/config.default.js)

### generateId

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- nodejs_version: '8'
- nodejs_version: '9'
- nodejs_version: '10'

install:
- nuget install redis-64 -excludeversion
Expand Down
21 changes: 18 additions & 3 deletions config/config.default.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
'use strict';

/**
* socket.io default config
* @member Config#io
* @property {String} SOME_KEY - some description todo
* The default `io` config.
*
* `init`: This is the same configs in
* https://github.com/socketio/engine.io/blob/master/README.md#methods-1
*
* `namespace`:
* i) If you wanna define your own namespace, just write something like:
* ```js
* namespace: {
'your_Namespace_Name': {
connectionMiddleware: [],
packetMiddleware: [],
},
* ```
* If you don't want namespace, just use '/' into your namespace config.
*
* ii) Create a folder called `middleware`, where to put your
* connectionMiddlewares and packetMiddlewares.
*/
exports.io = {
init: {},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"semver": "^5.4.1",
"socket.io-client": "^2.0.4",
"supertest": "^3.0.0",
"uws": "^8.14.1",
"uws": "10.148.0",
"webstorm-disable-index": "^1.2.0"
},
"engines": {
Expand All @@ -58,7 +58,7 @@
"index.d.ts"
],
"ci": {
"version": "8, 9",
"version": "8, 10",
"license": true,
"services": "redis-server"
},
Expand Down

0 comments on commit 2e85c4a

Please sign in to comment.