Skip to content

Commit

Permalink
Don't try to send messages over empty sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
freyacodes committed Nov 22, 2018
1 parent d556a47 commit eacccab
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,14 @@ class SocketContext internal constructor(
*/
fun send(payload: JSONObject) = send(payload.toString())

/**
* Either sends the payload now or queues it up
*/
fun send(payload: String) {
private fun send(payload: String) {
if (sessionPaused) {
resumeEventQueue.add(payload)
return
}

if (!session.isOpen) return

val undertowSession = (session as StandardWebSocketSession).nativeSession as UndertowSession
WebSockets.sendText(payload, undertowSession.webSocketChannel,
object : WebSocketCallback<Void> {
Expand Down

0 comments on commit eacccab

Please sign in to comment.