Skip to content

Commit

Permalink
support socket.io-client 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bobjiang1988 committed Sep 1, 2021
1 parent ec4cad3 commit 146b6e7
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 174 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Feature

Full feature socket.io style implemented, based-on `socket.io@2.x` version, such as:
Full feature socket.io style implemented, based-on `socket.io@3.x` version, such as:
- send message queue
- auto reconnect
- ping, pong
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"webpack-cli": "^3.3.11"
},
"dependencies": {
"socket.io-client": "^2.3.0"
"socket.io-client": "^3.1.0"
},
"scripts": {
"prepublish": "rm -rf ./lib ./dist && npm run build",
Expand Down
5 changes: 5 additions & 0 deletions src/websocket-constructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
WebSocket: require('ws'),
usingBrowserWebSocket: false,
defaultBinaryType: 'nodebuffer'
};
3 changes: 2 additions & 1 deletion webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
plugins: [
new webpack.NormalModuleReplacementPlugin(/debug/g, process.cwd() + '/support/debug.js'),
new webpack.NormalModuleReplacementPlugin(/^ws$/g, process.cwd() + '/src/wx-ws.js'),
new webpack.NormalModuleReplacementPlugin(/^.\/websocket-constructor$/g, process.cwd() + '/src/websocket-constructor.js'),
new webpack.NormalModuleReplacementPlugin(/^.\/transports\/index$/g, process.cwd() + '/src/transport.js'),
],
module: {
Expand All @@ -39,4 +40,4 @@ module.exports = {
}
}]
}
};
};
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
plugins: [
new webpack.NormalModuleReplacementPlugin(/debug/, process.cwd() + '/support/noop.js'),
new webpack.NormalModuleReplacementPlugin(/^ws$/g, process.cwd() + '/src/wx-ws.js'),
new webpack.NormalModuleReplacementPlugin(/^.\/websocket-constructor$/g, process.cwd() + '/src/websocket-constructor.js'),
new webpack.NormalModuleReplacementPlugin(/^.\/transports\/index$/g, process.cwd() + '/src/transport.js'),
],
module: {
Expand All @@ -38,4 +39,4 @@ module.exports = {
}
}]
}
};
};

0 comments on commit 146b6e7

Please sign in to comment.