Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rsocket-tcp-client

Package Overview
Dependencies
Maintainers
4
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsocket-tcp-client - npm Package Compare versions

Comparing version 0.0.19 to 0.0.21

LICENSE

14

build/index.js

@@ -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"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc