Initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.shr4pnel.ferretirc.net
|
||||
|
||||
import io.ktor.network.sockets.Socket
|
||||
import io.ktor.network.sockets.openWriteChannel
|
||||
import io.ktor.utils.io.ByteWriteChannel
|
||||
import io.ktor.utils.io.writeFully
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MessageWriter(socket: Socket, scope: CoroutineScope): MessageIO(socket, scope) {
|
||||
private lateinit var send: ByteWriteChannel
|
||||
|
||||
override suspend fun start() {
|
||||
send = socket.openWriteChannel()
|
||||
scope.launch {
|
||||
for (msg in outgoingMessages) {
|
||||
send.writeFully(msg.toWire())
|
||||
send.flush()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user