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