66 * @flow
77 */
88
9- 'use strict' ;
10-
119var util = require ( 'util' ) ;
1210var EventEmitter = require ( 'events' ) . EventEmitter ;
13- var {
14- NativeModules
15- } = require ( 'react-native' ) ;
11+ var { NativeModules } = require ( 'react-native' ) ;
1612var Sockets = NativeModules . TcpSockets ;
1713
1814var Socket = require ( './TcpSocket' ) ;
@@ -31,16 +27,16 @@ function TcpServer(connectionListener: (socket: Socket) => void) {
3127 this . _socket = new Socket ( ) ;
3228
3329 // $FlowFixMe: suppressing this error flow doesn't like EventEmitter
34- this . _socket . on ( 'connect' , function ( ) {
30+ this . _socket . on ( 'connect' , function ( ) {
3531 self . emit ( 'listening' ) ;
3632 } ) ;
3733 // $FlowFixMe: suppressing this error flow doesn't like EventEmitter
38- this . _socket . on ( 'connection' , function ( socket ) {
34+ this . _socket . on ( 'connection' , function ( socket ) {
3935 self . _connections ++ ;
4036 self . emit ( 'connection' , socket ) ;
4137 } ) ;
4238 // $FlowFixMe: suppressing this error flow doesn't like EventEmitter
43- this . _socket . on ( 'error' , function ( error ) {
39+ this . _socket . on ( 'error' , function ( error ) {
4440 self . emit ( 'error' , error ) ;
4541 } ) ;
4642
@@ -53,15 +49,15 @@ function TcpServer(connectionListener: (socket: Socket) => void) {
5349
5450util . inherits ( TcpServer , EventEmitter ) ;
5551
56- TcpServer . prototype . _debug = function ( ) {
52+ TcpServer . prototype . _debug = function ( ) {
5753 if ( __DEV__ ) {
5854 var args = [ ] . slice . call ( arguments ) ;
5955 console . log . apply ( console , args ) ;
6056 }
6157} ;
6258
6359// TODO : determine how to properly overload this with flow
64- TcpServer . prototype . listen = function ( ) : TcpServer {
60+ TcpServer . prototype . listen = function ( ) : TcpServer {
6561 var args = this . _socket . _normalizeConnectArgs ( arguments ) ;
6662 var options = args [ 0 ] ;
6763 var callback = args [ 1 ] ;
@@ -79,17 +75,23 @@ TcpServer.prototype.listen = function() : TcpServer {
7975 return this ;
8076} ;
8177
82- TcpServer . prototype . getConnections = function ( callback : ( err : ?any , count : number ) = > void ) {
78+ TcpServer . prototype . getConnections = function (
79+ callback : ( err : ?any , count : number ) = > void ,
80+ ) {
8381 if ( typeof callback === 'function' ) {
8482 callback . invoke ( null , this . _connections ) ;
8583 }
8684} ;
8785
88- TcpServer . prototype . address = function ( ) : { port: number , address : string , family : string } {
86+ TcpServer . prototype . address = function ( ) : {
87+ port: number ,
88+ address : string ,
89+ family : string ,
90+ } {
8991 return this . _socket ? this . _socket . address ( ) : { } ;
9092} ;
9193
92- TcpServer . prototype . close = function ( callback : ?( ) = > void ) {
94+ TcpServer . prototype . close = function ( callback : ?( ) = > void ) {
9395 if ( typeof callback === 'function' ) {
9496 if ( ! this . _socket ) {
9597 this . once ( 'close' , function close ( ) {
@@ -111,6 +113,8 @@ TcpServer.prototype.close = function(callback: ?() => void) {
111113} ;
112114
113115// unimplemented net.Server apis
114- TcpServer . prototype . ref = TcpServer . prototype . unref = function ( ) { /* nop */ } ;
116+ TcpServer . prototype . ref = TcpServer . prototype . unref = function ( ) {
117+ /* nop */
118+ } ;
115119
116120module . exports = TcpServer ;
0 commit comments