Skip to content

Commit

Permalink
fix: Fix write() callback invoking IOException objects
Browse files Browse the repository at this point in the history
Fixes #39
  • Loading branch information
Rapsssito committed Apr 6, 2020
1 parent 20d623b commit f07ee07
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void doInBackgroundGuarded(Void... params) {
@SuppressLint("StaticFieldLeak")
@SuppressWarnings("unused")
@ReactMethod
public void write(final Integer cId, final String base64String, final Callback callback) {
public void write(@NonNull final Integer cId, @NonNull final String base64String, @Nullable final Callback callback) {
new GuardedAsyncTask<Void, Void>(mReactContext.getExceptionHandler()) {
@Override
protected void doInBackgroundGuarded(Void... params) {
Expand All @@ -105,14 +105,14 @@ protected void doInBackgroundGuarded(Void... params) {
}
try {
socketClient.write(Base64.decode(base64String, Base64.NO_WRAP));
if (callback != null) {
callback.invoke();
}
} catch (IOException e) {
if (callback != null) {
callback.invoke(e);
return;
callback.invoke(e.toString());
}
}
if (callback != null) {
callback.invoke();
onError(cId, e.toString());
}
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Expand Down

0 comments on commit f07ee07

Please sign in to comment.