rsocket-tcp-server
Advanced tools
Comparing version 0.0.27 to 0.0.28
@@ -15,14 +15,10 @@ /** Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', {value: true}); | ||
exports.default = void 0; | ||
var _RSocketTCPServer = _interopRequireDefault(require('./RSocketTCPServer')); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : {default: obj}; | ||
} | ||
var _default = _RSocketTCPServer.default; | ||
exports.default = _default; | ||
import RSocketTCPServer from './RSocketTCPServer'; | ||
export default RSocketTCPServer; | ||
export type {ServerOptions} from './RSocketTCPServer'; |
@@ -15,24 +15,31 @@ /** Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', {value: true}); | ||
exports.default = void 0; | ||
var _rsocketTcpClient = require('rsocket-tcp-client'); | ||
import type {DuplexConnection} from 'rsocket-types'; | ||
import type {Encoders, TransportServer} from 'rsocket-core'; | ||
import {RSocketTcpConnection} from 'rsocket-tcp-client'; | ||
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}; | ||
} | ||
import EventEmitter from 'events'; | ||
import net from 'net'; | ||
import {Flowable} from 'rsocket-flowable'; | ||
export type ServerOptions = {| | ||
host?: string, | ||
port: number, | ||
serverFactory?: (onConnect: (socket: net.Socket) => void) => net.Server, | ||
|}; | ||
/** | ||
* A TCP transport server. | ||
*/ | ||
class RSocketTCPServer { | ||
constructor(options, encoders) { | ||
this._emitter = new _events.default(); | ||
export default class RSocketTCPServer implements TransportServer { | ||
_emitter: EventEmitter; | ||
_encoders: ?Encoders<*>; | ||
_options: ServerOptions; | ||
constructor(options: ServerOptions, encoders?: ?Encoders<*>) { | ||
this._emitter = new EventEmitter(); | ||
this._encoders = encoders; | ||
@@ -42,5 +49,5 @@ this._options = options; | ||
start() { | ||
return new _rsocketFlowable.Flowable((subscriber) => { | ||
let server; | ||
start(): Flowable<DuplexConnection> { | ||
return new Flowable(subscriber => { | ||
let server: ?net.Server; | ||
const onClose = () => { | ||
@@ -52,7 +59,5 @@ if (server) { | ||
}; | ||
const onError = (error) => subscriber.onError(error); | ||
const onConnection = (socket) => { | ||
subscriber.onNext( | ||
new _rsocketTcpClient.RSocketTcpConnection(socket, this._encoders) | ||
); | ||
const onError = error => subscriber.onError(error); | ||
const onConnection = (socket: net.Socket) => { | ||
subscriber.onNext(new RSocketTcpConnection(socket, this._encoders)); | ||
}; | ||
@@ -70,6 +75,5 @@ subscriber.onSubscribe({ | ||
}, | ||
request: (n) => { | ||
request: n => { | ||
if (!server) { | ||
const factory = | ||
this._options.serverFactory || _net.default.createServer; | ||
const factory = this._options.serverFactory || net.createServer; | ||
server = factory(onConnection); | ||
@@ -85,6 +89,5 @@ server.listen(this._options.port, this._options.host); | ||
stop() { | ||
stop(): void { | ||
this._emitter.emit('close'); | ||
} | ||
} | ||
exports.default = RSocketTCPServer; |
{ | ||
"name": "rsocket-tcp-server", | ||
"description": "RSocket TCP server", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"repository": { | ||
@@ -12,8 +12,8 @@ "type": "git", | ||
"dependencies": { | ||
"rsocket-core": "^0.0.27", | ||
"rsocket-flowable": "^0.0.27", | ||
"rsocket-tcp-client": "^0.0.27", | ||
"rsocket-types": "^0.0.27" | ||
"rsocket-core": "^0.0.28", | ||
"rsocket-flowable": "^0.0.28", | ||
"rsocket-tcp-client": "^0.0.28", | ||
"rsocket-types": "^0.0.28" | ||
}, | ||
"gitHead": "23da9b0e9377ba52d3294cf4763cbbf3de7ba7b1" | ||
"gitHead": "1dd3eb28183991d663392d87877225bf862946e2" | ||
} |
@@ -0,0 +0,0 @@ # rsocket-tcp-server |
Sorry, the diff of this file is not supported yet
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
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
15726
5
100
1
2
+ Addedrsocket-core@0.0.28(transitive)
+ Addedrsocket-flowable@0.0.28(transitive)
+ Addedrsocket-tcp-client@0.0.28(transitive)
+ Addedrsocket-types@0.0.28(transitive)
- Removedrsocket-core@0.0.27(transitive)
- Removedrsocket-flowable@0.0.27(transitive)
- Removedrsocket-tcp-client@0.0.27(transitive)
- Removedrsocket-types@0.0.27(transitive)
Updatedrsocket-core@^0.0.28
Updatedrsocket-flowable@^0.0.28
Updatedrsocket-tcp-client@^0.0.28
Updatedrsocket-types@^0.0.28