Skip to content

Commit

Permalink
feat(socket): check if socket exists before writing
Browse files Browse the repository at this point in the history
  • Loading branch information
cc-steina committed Jun 13, 2022
1 parent 755d7cb commit 2db5d6a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 345 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
@@ -1 +1 @@
github: [Rapsssito]
github: [curious-company]
322 changes: 0 additions & 322 deletions README.md

This file was deleted.

Expand Up @@ -88,18 +88,20 @@ public void startListening() {
* @param data data to be sent
*/
public void write(final int msgId, final byte[] data) {
writeExecutor.execute(new Runnable() {
@Override
public void run() {
try {
socket.getOutputStream().write(data);
receiverListener.onWritten(getId(), msgId, null);
} catch (IOException e) {
receiverListener.onWritten(getId(), msgId, e.toString());
receiverListener.onError(getId(), e.toString());
if (socket != null) {
writeExecutor.execute(new Runnable() {
@Override
public void run() {
try {
socket.getOutputStream().write(data);
receiverListener.onWritten(getId(), msgId, null);
} catch (IOException e) {
receiverListener.onWritten(getId(), msgId, e.toString());
receiverListener.onError(getId(), e.toString());
}
}
}
});
});
}
}

/**
Expand Down

0 comments on commit 2db5d6a

Please sign in to comment.