Skip to content

Commit 2ec0ca1

Browse files
committed
Refactoring to use ws napi modules
- removed native modules - change imports - add napi dependencies for native modules
1 parent 1f7ffba commit 2ec0ca1

11 files changed

+8
-398
lines changed

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
all:
2-
node-gyp configure build
3-
4-
clean:
5-
node-gyp clean
6-
71
autobahn:
82
@NODE_PATH=lib node test/autobahn-test-client.js --host=127.0.0.1 --port=9000
93

binding.gyp

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/BufferUtil.fallback.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

lib/BufferUtil.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/Validation.fallback.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/Validation.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/WebSocketConnection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var utils = require('./utils');
1919
var EventEmitter = require('events').EventEmitter;
2020
var WebSocketFrame = require('./WebSocketFrame');
2121
var BufferList = require('../vendor/FastBufferList');
22-
var Validation = require('./Validation').Validation;
22+
var isValidUTF8 = require('utf-8-validate');
2323
var bufferAllocUnsafe = utils.bufferAllocUnsafe;
2424
var bufferFromString = utils.bufferFromString;
2525

@@ -544,7 +544,7 @@ WebSocketConnection.prototype.processFrame = function(frame) {
544544
this._debug('-- Text Frame');
545545
if (this.assembleFragments) {
546546
if (frame.fin) {
547-
if (!Validation.isValidUTF8(frame.binaryPayload)) {
547+
if (!isValidUTF8(frame.binaryPayload)) {
548548
this.drop(WebSocketConnection.CLOSE_REASON_INVALID_DATA,
549549
'Invalid UTF-8 Data Received');
550550
return;
@@ -604,7 +604,7 @@ WebSocketConnection.prototype.processFrame = function(frame) {
604604
});
605605
break;
606606
case 0x01: // WebSocketOpcode.TEXT_FRAME
607-
if (!Validation.isValidUTF8(binaryPayload)) {
607+
if (!isValidUTF8(binaryPayload)) {
608608
this.drop(WebSocketConnection.CLOSE_REASON_INVALID_DATA,
609609
'Invalid UTF-8 Data Received');
610610
return;
@@ -686,7 +686,7 @@ WebSocketConnection.prototype.processFrame = function(frame) {
686686

687687
// If there is a textual description in the close frame, extract it.
688688
if (frame.binaryPayload.length > 1) {
689-
if (!Validation.isValidUTF8(frame.binaryPayload)) {
689+
if (!isValidUTF8(frame.binaryPayload)) {
690690
this.drop(WebSocketConnection.CLOSE_REASON_INVALID_DATA,
691691
'Invalid UTF-8 Data Received');
692692
return;

lib/WebSocketFrame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
***********************************************************************/
1616

17-
var bufferUtil = require('./BufferUtil').BufferUtil;
17+
var bufferUtil = require('bufferutil');
1818
var bufferAllocUnsafe = require('./utils').bufferAllocUnsafe;
1919

2020
const DECODE_HEADER = 1;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
},
2525
"homepage": "https://github.com/theturtle32/WebSocket-Node",
2626
"engines": {
27-
"node": ">=0.10.0"
27+
"node": ">=4.0.0"
2828
},
2929
"dependencies": {
30+
"bufferutil": "^4.0.1",
3031
"debug": "^2.2.0",
3132
"es5-ext": "^0.10.50",
3233
"nan": "^2.14.0",
3334
"typedarray-to-buffer": "^3.1.5",
35+
"utf-8-validate": "^5.0.2",
3436
"yaeti": "^0.0.6"
3537
},
3638
"devDependencies": {
@@ -46,7 +48,6 @@
4648
"verbose": false
4749
},
4850
"scripts": {
49-
"install": "(node-gyp rebuild 2> builderror.log) || (exit 0)",
5051
"test": "faucet test/unit",
5152
"gulp": "gulp"
5253
},

src/bufferutil.cc

Lines changed: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)