Increase buffer size for uploading image

This commit is contained in:
Him188 2020-04-13 10:50:58 +08:00
parent f7f3e88878
commit fe764d1fa8
3 changed files with 9 additions and 8 deletions

View File

@ -25,7 +25,6 @@ import kotlinx.io.core.Input
import kotlinx.io.core.discardExact
import kotlinx.io.core.readAvailable
import kotlinx.io.core.use
import kotlinx.io.pool.useInstance
import kotlinx.serialization.InternalSerializationApi
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
@ -109,8 +108,8 @@ internal object HighwayHelper {
) {
require(imageInput is Input || imageInput is InputStream || imageInput is ByteReadChannel) { "unsupported imageInput: ${imageInput::class.simpleName}" }
require(fileMd5.size == 16) { "bad md5. Required size=16, got ${fileMd5.size}" }
// require(ticket.size == 128) { "bad uKey. Required size=128, got ${ticket.size}" }
// require(commandId == 2 || commandId == 1) { "bad commandId. Must be 1 or 2" }
// require(ticket.size == 128) { "bad uKey. Required size=128, got ${ticket.size}" }
// require(commandId == 2 || commandId == 1) { "bad commandId. Must be 1 or 2" }
val socket = PlatformSocket()
socket.connect(serverIp, serverPort)

View File

@ -30,7 +30,8 @@ import net.mamoe.mirai.qqandroid.utils.io.serialization.toByteArray
import net.mamoe.mirai.utils.MiraiInternalAPI
@OptIn(MiraiInternalAPI::class, InternalSerializationApi::class)
internal fun createImageDataPacketSequence( // RequestDataTrans
internal fun createImageDataPacketSequence(
// RequestDataTrans
client: QQAndroidClient,
command: String,
appId: Int = 537062845,
@ -42,11 +43,11 @@ internal fun createImageDataPacketSequence( // RequestDataTrans
data: Any,
dataSize: Int,
fileMd5: ByteArray,
sizePerPacket: Int = 8192.coerceAtMost(ByteArrayPool.BUFFER_SIZE)
sizePerPacket: Int = ByteArrayPool.BUFFER_SIZE
): Flow<ByteReadPacket> {
ByteArrayPool.checkBufferSize(sizePerPacket)
require(data is Input || data is InputStream || data is ByteReadChannel) { "unsupported data: ${data::class.simpleName}" }
// require(ticket.size == 128) { "bad uKey. Required size=128, got ${ticket.size}" }
// require(ticket.size == 128) { "bad uKey. Required size=128, got ${ticket.size}" }
require(data !is ByteReadPacket || data.remaining.toInt() == dataSize) { "bad input. given dataSize=$dataSize, but actual readRemaining=${(data as ByteReadPacket).remaining}" }
val flow = when (data) {
@ -78,7 +79,7 @@ internal fun createImageDataPacketSequence( // RequestDataTrans
localeId = localId
),
msgSeghead = CSDataHighwayHead.SegHead(
// cacheAddr = 812157193,
// cacheAddr = 812157193,
datalength = chunkedInput.bufferSize,
dataoffset = offset,
filesize = dataSize.toLong(),

View File

@ -64,7 +64,8 @@ internal class DomainIpInfo(
internal class DomainIpList(
@JceId(0) val uDomainType: Int,
@JceId(1) val vIplist: List<DomainIpInfo>,
@JceId(2) val unknown: ByteArray // added
@JceId(2) val unknown: ByteArray? = null,
@JceId(4) val int: Int? = null// added
) : JceStruct
@Serializable