rsocket-tcp-server
Advanced tools
Comparing version 0.0.28 to 0.0.29-alpha.0
@@ -15,10 +15,14 @@ /** Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* @flow | ||
* | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', {value: true}); | ||
exports.default = void 0; | ||
import RSocketTCPServer from './RSocketTCPServer'; | ||
export default RSocketTCPServer; | ||
export type {ServerOptions} from './RSocketTCPServer'; | ||
var _RSocketTCPServer = _interopRequireDefault(require('./RSocketTCPServer')); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
var _default = _RSocketTCPServer.default; | ||
exports.default = _default; |
@@ -15,31 +15,24 @@ /** Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* @flow | ||
* | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', {value: true}); | ||
exports.default = void 0; | ||
import type {DuplexConnection} from 'rsocket-types'; | ||
import type {Encoders, TransportServer} from 'rsocket-core'; | ||
import {RSocketTcpConnection} from 'rsocket-tcp-client'; | ||
var _rsocketTcpClient = require('rsocket-tcp-client'); | ||
import EventEmitter from 'events'; | ||
import net from 'net'; | ||
import {Flowable} from 'rsocket-flowable'; | ||
var _events = _interopRequireDefault(require('events')); | ||
var _net = _interopRequireDefault(require('net')); | ||
var _rsocketFlowable = require('rsocket-flowable'); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
export type ServerOptions = {| | ||
host?: string, | ||
port: number, | ||
serverFactory?: (onConnect: (socket: net.Socket) => void) => net.Server, | ||
|}; | ||
/** | ||
* A TCP transport server. | ||
*/ | ||
export default class RSocketTCPServer implements TransportServer { | ||
_emitter: EventEmitter; | ||
_encoders: ?Encoders<*>; | ||
_options: ServerOptions; | ||
constructor(options: ServerOptions, encoders?: ?Encoders<*>) { | ||
this._emitter = new EventEmitter(); | ||
class RSocketTCPServer { | ||
constructor(options, encoders) { | ||
this._emitter = new _events.default(); | ||
this._encoders = encoders; | ||
@@ -49,5 +42,5 @@ this._options = options; | ||
start(): Flowable<DuplexConnection> { | ||
return new Flowable(subscriber => { | ||
let server: ?net.Server; | ||
start() { | ||
return new _rsocketFlowable.Flowable((subscriber) => { | ||
let server; | ||
const onClose = () => { | ||
@@ -59,5 +52,7 @@ if (server) { | ||
}; | ||
const onError = error => subscriber.onError(error); | ||
const onConnection = (socket: net.Socket) => { | ||
subscriber.onNext(new RSocketTcpConnection(socket, this._encoders)); | ||
const onError = (error) => subscriber.onError(error); | ||
const onConnection = (socket) => { | ||
subscriber.onNext( | ||
new _rsocketTcpClient.RSocketTcpConnection(socket, this._encoders) | ||
); | ||
}; | ||
@@ -75,5 +70,6 @@ subscriber.onSubscribe({ | ||
}, | ||
request: n => { | ||
request: (n) => { | ||
if (!server) { | ||
const factory = this._options.serverFactory || net.createServer; | ||
const factory = | ||
this._options.serverFactory || _net.default.createServer; | ||
server = factory(onConnection); | ||
@@ -89,5 +85,6 @@ server.listen(this._options.port, this._options.host); | ||
stop(): void { | ||
stop() { | ||
this._emitter.emit('close'); | ||
} | ||
} | ||
exports.default = RSocketTCPServer; |
{ | ||
"name": "rsocket-tcp-server", | ||
"description": "RSocket TCP server", | ||
"version": "0.0.28", | ||
"version": "0.0.29-alpha.0", | ||
"repository": { | ||
@@ -12,8 +12,8 @@ "type": "git", | ||
"dependencies": { | ||
"rsocket-core": "^0.0.28", | ||
"rsocket-flowable": "^0.0.28", | ||
"rsocket-tcp-client": "^0.0.28", | ||
"rsocket-types": "^0.0.28" | ||
"rsocket-core": "^0.0.29-alpha.0", | ||
"rsocket-flowable": "^0.0.29-alpha.0", | ||
"rsocket-tcp-client": "^0.0.29-alpha.0", | ||
"rsocket-types": "^0.0.29-alpha.0" | ||
}, | ||
"gitHead": "1dd3eb28183991d663392d87877225bf862946e2" | ||
"gitHead": "1b149fbd3dd66fbfdbaa91a8c95264214114c546" | ||
} |
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
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
19246
7
104
0
1
+ Addedrsocket-core@0.0.29-alpha.0(transitive)
+ Addedrsocket-flowable@0.0.29-alpha.0(transitive)
+ Addedrsocket-tcp-client@0.0.29-alpha.0(transitive)
+ Addedrsocket-types@0.0.29-alpha.0(transitive)
- Removedrsocket-core@0.0.28(transitive)
- Removedrsocket-flowable@0.0.28(transitive)
- Removedrsocket-tcp-client@0.0.28(transitive)
- Removedrsocket-types@0.0.28(transitive)
Updatedrsocket-core@^0.0.29-alpha.0