otakusenpai
10/10/2018, 12:17 PMinput.read { byteBuffer }
Where input is a ByteReadChannel object ?otakusenpai
10/10/2018, 12:24 PMotakusenpai
10/10/2018, 12:25 PMvar byteBuffer = ByteBuffer.wrap(ByteArray(512))
input.read { byteBuffer }
data = String(byteBuffer.array(), Charset.forName("ASCII"))
println("Data size = ${data.length}")
otakusenpai
10/10/2018, 12:30 PMvar byteBuffer = ByteBuffer.wrap(ByteArray(512))
val bbToString = { data = String(byteBuffer.array(), Charset.forName("ASCII")) }
input.read { byteBuffer -> bbToString }
But its giving me this errorotakusenpai
10/10/2018, 12:31 PMjava.lang.Exception: BasicConnection.kt: Didn't receive data from connection!
at com.github.otakusenpai.testbot.connection.BasicConnection$receiveData$1.doResume(BasicConnection.kt:83)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:166)
at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:69)
at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
at com.github.otakusenpai.testbot.connection.BasicConnection.receiveData(BasicConnection.kt:73)
at com.github.otakusenpai.testbot.MainKt.main(main.kt:89)
Received data: null
cy
10/10/2018, 12:52 PMread{ }
lambda has Unit
return type so I don't get what are you trying to docy
10/10/2018, 12:52 PMreadAvailable
or readFully
otakusenpai
10/10/2018, 12:52 PMotakusenpai
10/10/2018, 12:52 PMcy
10/10/2018, 12:52 PMread
if you are sure that you really need exactly this functionotakusenpai
10/10/2018, 12:53 PMcy
10/10/2018, 12:53 PMotakusenpai
10/10/2018, 12:54 PMcy
10/10/2018, 12:54 PMcy
10/10/2018, 12:55 PMcy
10/10/2018, 12:55 PM<https://github.com/Kotlin/kotlinx-io/blob/eap13/kotlinx-coroutines-io/kotlinx-coroutines-io-jvm/src/main/kotlin/kotlinx/coroutines/experimental/io/ByteReadChannelJVM.kt#L152>
otakusenpai
10/10/2018, 12:56 PMcy
10/10/2018, 12:57 PMotakusenpai
10/10/2018, 12:58 PMcy
10/10/2018, 1:00 PMotakusenpai
10/10/2018, 1:00 PMotakusenpai
10/10/2018, 1:00 PMcy
10/10/2018, 1:00 PMDeactivated User
10/10/2018, 4:07 PM