mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-10 04:00:08 +08:00
Add send(ByteArray)
This commit is contained in:
parent
b3e9d553aa
commit
d6d1f2c74d
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user