mirror of
https://github.com/tursom/TursomServer.git
synced 2024-12-29 14:30:55 +08:00
add AsyncChannelEnhance.kt
This commit is contained in:
parent
e8b6d29c4e
commit
ad50218e94
@ -0,0 +1,23 @@
|
||||
package cn.tursom.channel
|
||||
|
||||
import cn.tursom.channel.enhance.ChannelReader
|
||||
import cn.tursom.channel.enhance.ChannelWriter
|
||||
import cn.tursom.channel.enhance.EnhanceChannel
|
||||
import cn.tursom.channel.enhance.impl.*
|
||||
import cn.tursom.core.buffer.ByteBuffer
|
||||
|
||||
fun AsyncChannel.reader(): ChannelReader<ByteBuffer> = ChannelReaderImpl(this)
|
||||
fun AsyncChannel.writer(): ChannelWriter<ByteBuffer> = ChannelWriterImpl(this)
|
||||
fun AsyncChannel.enhance(): EnhanceChannel<ByteBuffer, ByteBuffer> = EnhanceChannel(this)
|
||||
|
||||
fun ChannelReader<ByteBuffer>.lengthField(): ChannelReader<ByteBuffer> = LengthFieldBasedFrameReader(this)
|
||||
fun ChannelWriter<ByteBuffer>.lengthField(): ChannelWriter<ByteBuffer> = LengthFieldPrependWriter(this)
|
||||
fun EnhanceChannel<ByteBuffer, ByteBuffer>.lengthField(): EnhanceChannel<ByteBuffer, ByteBuffer> = LengthFieldChannel(this)
|
||||
|
||||
fun ChannelReader<ByteBuffer>.string() = StringReader(this)
|
||||
fun ChannelWriter<ByteBuffer>.string() = StringWriter(this)
|
||||
fun EnhanceChannel<ByteBuffer, ByteBuffer>.string() = StringChannel(this)
|
||||
|
||||
fun ChannelWriter<String>.stringObjectWriter(
|
||||
toString: (obj: Any) -> String = { it.toString() }
|
||||
): StringObjectWriter = StringObjectWriter(this, toString)
|
Loading…
Reference in New Issue
Block a user