rsocket-tcp-client
Advanced tools
Comparing version 0.0.19 to 0.0.21
@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* | ||
* | ||
*/ | ||
@@ -21,6 +21,12 @@ | ||
Object.defineProperty(exports, '__esModule', {value: true}); | ||
exports.RSocketTcpConnection = undefined; | ||
Object.defineProperty(exports, 'RSocketTcpConnection', { | ||
enumerable: true, | ||
get: function () { | ||
return _RSocketTcpClient.RSocketTcpConnection; | ||
}, | ||
}); | ||
exports.default = void 0; | ||
var _RSocketTcpClient = require('./RSocketTcpClient'); | ||
exports.default = _RSocketTcpClient.RSocketTcpClient; | ||
exports.RSocketTcpConnection = _RSocketTcpClient.RSocketTcpConnection; | ||
var _default = _RSocketTcpClient.RSocketTcpClient; | ||
exports.default = _default; |
@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* | ||
* | ||
*/ | ||
@@ -21,11 +21,8 @@ | ||
Object.defineProperty(exports, '__esModule', {value: true}); | ||
exports.RSocketTlsClient = (exports.RSocketTcpClient = (exports.RSocketTcpConnection = undefined)); | ||
exports.RSocketTlsClient = exports.RSocketTcpClient = exports.RSocketTcpConnection = void 0; | ||
var _net = require('net'); | ||
var _net2 = _interopRequireDefault(_net); | ||
var _tls = require('tls'); | ||
var _tls2 = _interopRequireDefault(_tls); | ||
var _net = _interopRequireDefault(require('net')); | ||
var _tls = _interopRequireDefault(require('tls')); | ||
var _rsocketFlowable = require('rsocket-flowable'); | ||
var _invariant = require('fbjs/lib/invariant'); | ||
var _invariant2 = _interopRequireDefault(_invariant); | ||
var _invariant = _interopRequireDefault(require('fbjs/lib/invariant')); | ||
var _rsocketCore = require('rsocket-core'); | ||
@@ -37,23 +34,46 @@ | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
/** | ||
* A TCP transport client for use in node environments. | ||
*/ | ||
* A TCP transport client for use in node environments. | ||
*/ | ||
class RSocketTcpConnection { | ||
constructor(socket, encoders) { | ||
this._handleError = error => { | ||
error = error || | ||
new Error('RSocketTcpClient: Socket closed unexpectedly.'); | ||
this._close(error); | ||
}; | ||
this._handleData = chunk => { | ||
try { | ||
const frames = this._readFrames(chunk); | ||
frames.forEach(frame => { | ||
this._receivers.forEach(subscriber => subscriber.onNext(frame)); | ||
}); | ||
} catch (error) { | ||
this._handleError(error); | ||
_defineProperty( | ||
this, | ||
'_handleError', | ||
(error) => { | ||
error = | ||
error || new Error('RSocketTcpClient: Socket closed unexpectedly.'); | ||
this._close(error); | ||
} | ||
}; | ||
); | ||
_defineProperty( | ||
this, | ||
'_handleData', | ||
(chunk) => { | ||
try { | ||
const frames = this._readFrames(chunk); | ||
frames.forEach((frame) => { | ||
this._receivers.forEach((subscriber) => subscriber.onNext(frame)); | ||
}); | ||
} catch (error) { | ||
this._handleError(error); | ||
} | ||
} | ||
); | ||
this._buffer = (0, _rsocketCore.createBuffer)(0); | ||
@@ -86,3 +106,3 @@ this._encoders = encoders; | ||
connectionStatus() { | ||
return new _rsocketFlowable.Flowable(subscriber => { | ||
return new _rsocketFlowable.Flowable((subscriber) => { | ||
subscriber.onSubscribe({ | ||
@@ -100,3 +120,3 @@ cancel: () => { | ||
receive() { | ||
return new _rsocketFlowable.Flowable(subject => { | ||
return new _rsocketFlowable.Flowable((subject) => { | ||
subject.onSubscribe({ | ||
@@ -121,8 +141,8 @@ cancel: () => { | ||
}, | ||
onError: error => { | ||
onError: (error) => { | ||
subscription && this._senders.delete(subscription); | ||
this._handleError(error); | ||
}, | ||
onNext: frame => this._writeFrame(frame), | ||
onSubscribe: _subscription => { | ||
onNext: (frame) => this._writeFrame(frame), | ||
onSubscribe: (_subscription) => { | ||
subscription = _subscription; | ||
@@ -139,3 +159,3 @@ this._senders.add(subscription); | ||
this._status = status; | ||
this._statusSubscribers.forEach(subscriber => subscriber.onNext(status)); | ||
this._statusSubscribers.forEach((subscriber) => subscriber.onNext(status)); | ||
} | ||
@@ -151,3 +171,3 @@ _close(error) { | ||
this.setConnectionStatus(status); | ||
this._receivers.forEach(subscriber => { | ||
this._receivers.forEach((subscriber) => { | ||
if (error) { | ||
@@ -160,3 +180,3 @@ subscriber.onError(error); | ||
this._receivers.clear(); | ||
this._senders.forEach(subscription => subscription.cancel()); | ||
this._senders.forEach((subscription) => subscription.cancel()); | ||
this._senders.clear(); | ||
@@ -188,3 +208,3 @@ const socket = this._socket; | ||
); | ||
(0, _invariant2.default)( | ||
(0, _invariant.default)( | ||
this._socket, | ||
@@ -200,17 +220,21 @@ 'RSocketTcpClient: Cannot send frame, not connected.' | ||
} | ||
exports.RSocketTcpConnection = RSocketTcpConnection; | ||
/** | ||
* A TCP transport client for use in node environments. | ||
*/ | ||
* A TCP transport client for use in node environments. | ||
*/ exports.RSocketTcpConnection = RSocketTcpConnection; | ||
class RSocketTcpClient extends RSocketTcpConnection { | ||
constructor(options, encoders) { | ||
super(null, encoders); | ||
this._handleOpened = () => { | ||
this.setConnectionStatus(_rsocketTypes.CONNECTION_STATUS.CONNECTED); | ||
}; | ||
_defineProperty( | ||
this, | ||
'_handleOpened', | ||
() => { | ||
this.setConnectionStatus(_rsocketTypes.CONNECTION_STATUS.CONNECTED); | ||
} | ||
); | ||
this._options = options; | ||
} | ||
connect() { | ||
(0, _invariant2.default)( | ||
(0, _invariant.default)( | ||
this.getConnectionState().kind === 'NOT_CONNECTED', | ||
@@ -221,3 +245,3 @@ 'RSocketTcpClient: Cannot connect(), a connection is already ' + | ||
this.setConnectionStatus(_rsocketTypes.CONNECTION_STATUS.CONNECTING); | ||
const socket = _net2.default.connect(this._options); | ||
const socket = _net.default.connect(this._options); | ||
this.setupSocket(socket); | ||
@@ -227,17 +251,21 @@ socket.on('connect', this._handleOpened); | ||
} | ||
exports.RSocketTcpClient = RSocketTcpClient; | ||
/** | ||
* A TLS transport client for use in node environments. | ||
*/ | ||
* A TLS transport client for use in node environments. | ||
*/ exports.RSocketTcpClient = RSocketTcpClient; | ||
class RSocketTlsClient extends RSocketTcpConnection { | ||
constructor(options, encoders) { | ||
super(null, encoders); | ||
this._handleOpened = () => { | ||
this.setConnectionStatus(_rsocketTypes.CONNECTION_STATUS.CONNECTED); | ||
}; | ||
_defineProperty( | ||
this, | ||
'_handleOpened', | ||
() => { | ||
this.setConnectionStatus(_rsocketTypes.CONNECTION_STATUS.CONNECTED); | ||
} | ||
); | ||
this._options = options; | ||
} | ||
connect() { | ||
(0, _invariant2.default)( | ||
(0, _invariant.default)( | ||
this.getConnectionState().kind === 'NOT_CONNECTED', | ||
@@ -248,3 +276,3 @@ 'RSocketTlsClient: Cannot connect(), a connection is already ' + | ||
this.setConnectionStatus(_rsocketTypes.CONNECTION_STATUS.CONNECTING); | ||
const socket = _tls2.default.connect(this._options); | ||
const socket = _tls.default.connect(this._options); | ||
this.setupSocket(socket); | ||
@@ -251,0 +279,0 @@ socket.on('connect', this._handleOpened); |
{ | ||
"name": "rsocket-tcp-client", | ||
"description": "RSocket TCP client for use in Node.js environments", | ||
"version": "0.0.19", | ||
"version": "0.0.21", | ||
"repository": { | ||
@@ -12,6 +12,7 @@ "type": "git", | ||
"dependencies": { | ||
"fbjs": "^1.0.0", | ||
"rsocket-core": "^0.0.19", | ||
"rsocket-flowable": "^0.0.14" | ||
} | ||
"fbjs": "^2.0.0", | ||
"rsocket-core": "^0.0.21", | ||
"rsocket-flowable": "^0.0.21" | ||
}, | ||
"gitHead": "c10250d8bf2904101ebc61ea15f85e493cf005f1" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28178
6
284
3
+ Addedcore-js@3.39.0(transitive)
+ Addedcross-fetch@3.1.8(transitive)
+ Addedfbjs@2.0.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedrsocket-core@0.0.21(transitive)
+ Addedrsocket-flowable@0.0.21(transitive)
+ Addedrsocket-types@0.0.21(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedencoding@0.1.13(transitive)
- Removedfbjs@1.0.0(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedieee754@1.2.1(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisomorphic-fetch@2.2.1(transitive)
- Removednode-fetch@1.7.3(transitive)
- Removedrsocket-core@0.0.19(transitive)
- Removedrsocket-flowable@0.0.14(transitive)
- Removedrsocket-types@0.0.16(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)
Updatedfbjs@^2.0.0
Updatedrsocket-core@^0.0.21
Updatedrsocket-flowable@^0.0.21