Skip to content

Commit

Permalink
check websocket readyState without var.now()
Browse files Browse the repository at this point in the history
  • Loading branch information
yurique authored Jan 10, 2022
1 parent 8109af3 commit dec2343
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ class WebSocket[Receive, Send](
}

private def trySend(): Unit = {
if (connectedVar.now()) {
maybeWS.foreach { ws =>
sendBuffer.foreach { message =>
sender(ws, message)
}
sendBuffer.clear()
}
} else {
val connectedWS = maybeWS.filter(_.readyState == 1 /* OPEN */ )
if (js.isUndefined(connectedWS)) {
if (!bufferWhenDisconnected) {
sendBuffer.clear()
} else if (sendBuffer.size > bufferSize) {
sendBuffer.drop(sendBuffer.size - bufferSize)
}
}
connectedWS.foreach { ws =>
sendBuffer.foreach { message =>
sender(ws, message)
}
sendBuffer.clear()
}
}

def connect[El <: ReactiveElement.Base]: Binder[El] =
Expand Down

0 comments on commit dec2343

Please sign in to comment.