Skip to content

Commit 23c7df5

Browse files
committed
Fix socket not connected exception
If the socket was not connected, exception was raised. Need to add some check
1 parent 9052a43 commit 23c7df5

File tree

1 file changed

+1
-1
lines changed
  • RxSocketClient/src/main/java/moe/codeest/rxsocketclient/post

1 file changed

+1
-1
lines changed

RxSocketClient/src/main/java/moe/codeest/rxsocketclient/post/AsyncPoster.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class AsyncPoster(private val mSocketClient: SocketClient, private val mExecutor
3838

3939
override fun run() {
4040
val pendingPost = queue.poll() ?: throw IllegalStateException("No pending post available")
41-
mSocketClient.mSocket.getOutputStream()?.apply {
41+
mSocketClient.mSocket.takeIf { it.isConnected }?.getOutputStream()?.apply {
4242
try {
4343
write(pendingPost.data)
4444
flush()

0 commit comments

Comments
 (0)