Skip to content

Not Working with React Native 0.62 #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
95ae7b5
Support CocoaPods
ahizzle Dec 1, 2017
3ac4b76
Don't override process if it defined
olegdeezus Feb 27, 2018
ea9927c
Merge pull request #1 from olegdizus/dont-override-process
olegdeezus Feb 27, 2018
5245161
Pull info from app build.gradle if available
phillbaker Jun 27, 2019
6eed74b
Update package info, version.
phillbaker Jun 28, 2019
7a1fc5f
Merge pull request #1 from olegdeezus/master
phillbaker Aug 9, 2019
798737a
Merge pull request #2 from atvenu/master
phillbaker Aug 10, 2019
39b067e
Update build.gradle
Sep 23, 2019
393c836
Allow listening to all interfaces instead of just localhost
xploSEoF Oct 3, 2019
5c22e37
Fix the global.process issue in TcpSocket.js while preserving debugging
xploSEoF Oct 3, 2019
6e18e7d
Maintain callback queues accordingly
xploSEoF Oct 3, 2019
0d38301
Merge pull request #8 from eventengineering/bugfix/process-override
phillbaker Oct 4, 2019
c29cf0f
Merge pull request #7 from eventengineering/bugfix/interface-selection
phillbaker Oct 6, 2019
6a3b1bc
Bump patch version for fixes.
phillbaker Oct 9, 2019
e097e9c
Upgrade for Android API 29 , using gradle 6, react-native 0.61+, test…
ralic Dec 4, 2019
6e48b34
Bump to use AndroidX
chris-griffin Nov 12, 2019
5c2b2a5
Bump major version for androidx support.
phillbaker Apr 4, 2020
356e18c
Merge pull request #9 from eventengineering/bugfix/callback-queues
aprock Apr 9, 2020
d803b5f
Merge pull request #10 from SaferNodeJS/master
aprock Apr 9, 2020
9044772
Merge pull request #6 from PerspectivesLab/master
aprock Apr 9, 2020
98fbc80
Fix React Native 0.62 compatability
KDederichs Apr 15, 2020
0de2f7b
Resolve local port number when listening to port 0
olehs May 27, 2020
ec3841f
Merge pull request #11 from KDederichs/RN0.62
aprock Jun 15, 2020
025d373
(fix) remove CocoaAsyncSocket deps
Apr 3, 2021
c72dd71
Merge pull request #14 from zjhiphop/master
aprock May 28, 2022
be5f656
Merge pull request #12 from olehs/patch-1
aprock May 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ __Note for iOS:__ If your react-native version < 0.40 install with this tag inst
```
npm install [email protected] --save
```
## if using Cocoapods

Update the following line with your path to `node_modules/` and add it to your
podfile:

```ruby
pod 'TcpSockets', :path => '../node_modules/react-native-tcp'
```

## Link in the native dependency

Expand Down
32 changes: 18 additions & 14 deletions TcpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
* @flow
*/

'use strict';

var util = require('util');
var EventEmitter = require('events').EventEmitter;
var {
NativeModules
} = require('react-native');
var { NativeModules } = require('react-native');
var Sockets = NativeModules.TcpSockets;

var Socket = require('./TcpSocket');
Expand All @@ -31,16 +27,16 @@ function TcpServer(connectionListener: (socket: Socket) => void) {
this._socket = new Socket();

// $FlowFixMe: suppressing this error flow doesn't like EventEmitter
this._socket.on('connect', function() {
this._socket.on('connect', function () {
self.emit('listening');
});
// $FlowFixMe: suppressing this error flow doesn't like EventEmitter
this._socket.on('connection', function(socket) {
this._socket.on('connection', function (socket) {
self._connections++;
self.emit('connection', socket);
});
// $FlowFixMe: suppressing this error flow doesn't like EventEmitter
this._socket.on('error', function(error) {
this._socket.on('error', function (error) {
self.emit('error', error);
});

Expand All @@ -53,15 +49,15 @@ function TcpServer(connectionListener: (socket: Socket) => void) {

util.inherits(TcpServer, EventEmitter);

TcpServer.prototype._debug = function() {
TcpServer.prototype._debug = function () {
if (__DEV__) {
var args = [].slice.call(arguments);
console.log.apply(console, args);
}
};

// TODO : determine how to properly overload this with flow
TcpServer.prototype.listen = function() : TcpServer {
TcpServer.prototype.listen = function (): TcpServer {
var args = this._socket._normalizeConnectArgs(arguments);
var options = args[0];
var callback = args[1];
Expand All @@ -79,17 +75,23 @@ TcpServer.prototype.listen = function() : TcpServer {
return this;
};

TcpServer.prototype.getConnections = function(callback: (err: ?any, count: number) => void) {
TcpServer.prototype.getConnections = function (
callback: (err: ?any, count: number) => void,
) {
if (typeof callback === 'function') {
callback.invoke(null, this._connections);
}
};

TcpServer.prototype.address = function() : { port: number, address: string, family: string } {
TcpServer.prototype.address = function (): {
port: number,
address: string,
family: string,
} {
return this._socket ? this._socket.address() : {};
};

TcpServer.prototype.close = function(callback: ?() => void) {
TcpServer.prototype.close = function (callback: ?() => void) {
if (typeof callback === 'function') {
if (!this._socket) {
this.once('close', function close() {
Expand All @@ -111,6 +113,8 @@ TcpServer.prototype.close = function(callback: ?() => void) {
};

// unimplemented net.Server apis
TcpServer.prototype.ref = TcpServer.prototype.unref = function() { /* nop */ };
TcpServer.prototype.ref = TcpServer.prototype.unref = function () {
/* nop */
};

module.exports = TcpServer;
Loading