Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
hopefully fix ktor update issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Oct 28, 2018
1 parent e07ad3c commit e586286
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildscript {
}

group 'io.kweb'
version '0.3.8'
version '0.3.9'

apply plugin: 'java'

Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/io/kweb/Kweb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import io.kweb.browserConnection.KwebClientConnection.Caching
import io.kweb.dev.hotswap.KwebHotswapPlugin
import io.kweb.plugins.KWebPlugin
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.time.delay
import org.apache.commons.io.IOUtils
import java.io.*
Expand Down Expand Up @@ -207,8 +206,7 @@ class Kweb(val port: Int,

webSocket("/ws") {

val hello = gson.fromJson<Client2ServerMessage>((incoming as Text).readText())

val hello = gson.fromJson<Client2ServerMessage>(((incoming.receive() as Text).readText()))

if (hello.hello == null) {
throw RuntimeException("First message from client isn't 'hello'")
Expand All @@ -227,7 +225,7 @@ class Kweb(val port: Int,


try {
incoming.consumeEach { frame ->
for (frame in incoming) {
try {
logger.debug { "Message received from client" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.kweb.browserConnection
import io.ktor.http.cio.websocket.*
import io.ktor.http.cio.websocket.Frame.Text
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.channels.Channel
import mu.KotlinLogging
import java.util.concurrent.ConcurrentLinkedQueue

Expand All @@ -12,7 +12,7 @@ private val logger = KotlinLogging.logger {}
sealed class KwebClientConnection {
abstract fun send(message: String)

@ObsoleteCoroutinesApi // TODO: For Channel.consumeEach, which will apparently become obsolete
//@ObsoleteCoroutinesApi // TODO: For Channel.consumeEach, which will apparently become obsolete
class WebSocket(private val channel: WebSocketSession) : KwebClientConnection() {

@Volatile var sendCount = 0
Expand All @@ -21,7 +21,9 @@ sealed class KwebClientConnection {

init {
GlobalScope.launch {
sendBuffer.consumeEach { channel.send(it) }
for (frame in sendBuffer) {
channel.send(frame)
}
}

}
Expand Down

0 comments on commit e586286

Please sign in to comment.