Merge pull request #4 from bettiah/master

fix for hang on activity suspend/resume
This commit is contained in:
Andy Prock 2016-06-17 09:21:07 -07:00 committed by GitHub
commit 575f9e660e
1 changed files with 15 additions and 0 deletions

View File

@ -142,6 +142,9 @@ public final class TcpSockets extends ReactContextBaseJavaModule implements TcpS
@Override
public void onConnection(Integer serverId, Integer clientId, InetSocketAddress socketAddress) {
if (mShuttingDown) {
return;
}
WritableMap eventParams = Arguments.createMap();
eventParams.putInt("id", clientId);
@ -160,6 +163,9 @@ public final class TcpSockets extends ReactContextBaseJavaModule implements TcpS
@Override
public void onConnect(Integer id, InetSocketAddress address) {
if (mShuttingDown) {
return;
}
WritableMap eventParams = Arguments.createMap();
eventParams.putString("address", address.getHostName());
eventParams.putInt("port", address.getPort());
@ -173,6 +179,9 @@ public final class TcpSockets extends ReactContextBaseJavaModule implements TcpS
@Override
public void onData(Integer id, byte[] data) {
if (mShuttingDown) {
return;
}
ReactContext reactContext = TcpSockets.this.getReactApplicationContext();
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
@ -181,6 +190,9 @@ public final class TcpSockets extends ReactContextBaseJavaModule implements TcpS
@Override
public void onClose(Integer id, String error) {
if (mShuttingDown) {
return;
}
if (error != null) {
onError(id, error);
}
@ -193,6 +205,9 @@ public final class TcpSockets extends ReactContextBaseJavaModule implements TcpS
@Override
public void onError(Integer id, String error) {
if (mShuttingDown) {
return;
}
ReactContext reactContext = TcpSockets.this.getReactApplicationContext();
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)