Commit d6d1f2c7 authored by Him188's avatar Him188

Add send(ByteArray)

parent b3e9d553
......@@ -34,6 +34,14 @@ actual class PlatformSocket : Closeable {
@PublishedApi
internal lateinit var readChannel: ByteReadChannel
actual suspend inline fun send(packet: ByteArray, offset: Int, length: Int) {
try {
writeChannel.writeFully(packet, offset, length)
} catch (e: Exception) {
throw SendPacketInternalException(e)
}
}
/**
* @throws SendPacketInternalException
*/
......
......@@ -12,6 +12,11 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
expect class PlatformSocket() : Closeable {
suspend fun connect(serverHost: String, serverPort: Int)
/**
* @throws SendPacketInternalException
*/
suspend inline fun send(packet: ByteArray, offset: Int = 0, length: Int = packet.size - offset)
/**
* @throws SendPacketInternalException
*/
......
......@@ -34,6 +34,14 @@ actual class PlatformSocket : Closeable {
@PublishedApi
internal lateinit var readChannel: ByteReadChannel
actual suspend inline fun send(packet: ByteArray, offset: Int, length: Int) {
try {
writeChannel.writeFully(packet, offset, length)
} catch (e: Exception) {
throw SendPacketInternalException(e)
}
}
/**
* @throws SendPacketInternalException
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment