Skip to content

Commit

Permalink
Refactoring to use ws napi modules
Browse files Browse the repository at this point in the history
  - removed native modules
  - change imports
  - add napi dependencies for native modules
  • Loading branch information
andreek committed Dec 10, 2019
1 parent 1f7ffba commit 481144a
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 399 deletions.
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
all:
node-gyp configure build

clean:
node-gyp clean

autobahn:
@NODE_PATH=lib node test/autobahn-test-client.js --host=127.0.0.1 --port=9000

Expand Down
18 changes: 0 additions & 18 deletions binding.gyp

This file was deleted.

52 changes: 0 additions & 52 deletions lib/BufferUtil.fallback.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/BufferUtil.js

This file was deleted.

12 changes: 0 additions & 12 deletions lib/Validation.fallback.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/Validation.js

This file was deleted.

8 changes: 4 additions & 4 deletions lib/WebSocketConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var utils = require('./utils');
var EventEmitter = require('events').EventEmitter;
var WebSocketFrame = require('./WebSocketFrame');
var BufferList = require('../vendor/FastBufferList');
var Validation = require('./Validation').Validation;
var isValidUTF8 = require('utf-8-validate');
var bufferAllocUnsafe = utils.bufferAllocUnsafe;
var bufferFromString = utils.bufferFromString;

Expand Down Expand Up @@ -544,7 +544,7 @@ WebSocketConnection.prototype.processFrame = function(frame) {
this._debug('-- Text Frame');
if (this.assembleFragments) {
if (frame.fin) {
if (!Validation.isValidUTF8(frame.binaryPayload)) {
if (!isValidUTF8(frame.binaryPayload)) {
this.drop(WebSocketConnection.CLOSE_REASON_INVALID_DATA,
'Invalid UTF-8 Data Received');
return;
Expand Down Expand Up @@ -604,7 +604,7 @@ WebSocketConnection.prototype.processFrame = function(frame) {
});
break;
case 0x01: // WebSocketOpcode.TEXT_FRAME
if (!Validation.isValidUTF8(binaryPayload)) {
if (!isValidUTF8(binaryPayload)) {
this.drop(WebSocketConnection.CLOSE_REASON_INVALID_DATA,
'Invalid UTF-8 Data Received');
return;
Expand Down Expand Up @@ -686,7 +686,7 @@ WebSocketConnection.prototype.processFrame = function(frame) {

// If there is a textual description in the close frame, extract it.
if (frame.binaryPayload.length > 1) {
if (!Validation.isValidUTF8(frame.binaryPayload)) {
if (!isValidUTF8(frame.binaryPayload)) {
this.drop(WebSocketConnection.CLOSE_REASON_INVALID_DATA,
'Invalid UTF-8 Data Received');
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/WebSocketFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
***********************************************************************/

var bufferUtil = require('./BufferUtil').BufferUtil;
var bufferUtil = require('bufferutil');
var bufferAllocUnsafe = require('./utils').bufferAllocUnsafe;

const DECODE_HEADER = 1;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
},
"homepage": "https://github.com/theturtle32/WebSocket-Node",
"engines": {
"node": ">=0.10.0"
"node": ">=4.0.0"
},
"dependencies": {
"bufferutil": "^4.0.1",
"debug": "^2.2.0",
"es5-ext": "^0.10.50",
"nan": "^2.14.0",
"typedarray-to-buffer": "^3.1.5",
"utf-8-validate": "^5.0.2",
"yaeti": "^0.0.6"
},
"devDependencies": {
Expand All @@ -46,7 +47,6 @@
"verbose": false
},
"scripts": {
"install": "(node-gyp rebuild 2> builderror.log) || (exit 0)",
"test": "faucet test/unit",
"gulp": "gulp"
},
Expand Down
121 changes: 0 additions & 121 deletions src/bufferutil.cc

This file was deleted.

Loading

0 comments on commit 481144a

Please sign in to comment.