mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
parent
77504d68fd
commit
8fadd0016a
@ -176,9 +176,6 @@ internal object MsgSvc: BaseSvc() {
|
|||||||
fromId: String = peedId,
|
fromId: String = peedId,
|
||||||
retryCnt: Int = 3
|
retryCnt: Int = 3
|
||||||
): Result<Pair<Long, Int>> {
|
): Result<Pair<Long, Int>> {
|
||||||
//LogCenter.log(message.toString(), Level.ERROR)
|
|
||||||
//callback.msgHash = result.second 什么垃圾代码,万一cb比你快,你不就寄了?
|
|
||||||
|
|
||||||
// 主动临时消息
|
// 主动临时消息
|
||||||
when (chatType) {
|
when (chatType) {
|
||||||
MsgConstant.KCHATTYPETEMPC2CFROMGROUP -> {
|
MsgConstant.KCHATTYPETEMPC2CFROMGROUP -> {
|
||||||
@ -188,13 +185,7 @@ internal object MsgSvc: BaseSvc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val result = MessageHelper.sendMessageWithoutMsgId(
|
val result = MessageHelper.sendMessageWithoutMsgId(chatType, peedId, message, fromId, MessageCallback(peedId, 0))
|
||||||
chatType,
|
|
||||||
peedId,
|
|
||||||
message,
|
|
||||||
fromId,
|
|
||||||
MessageCallback(peedId, 0)
|
|
||||||
)
|
|
||||||
return if (result.isFailure
|
return if (result.isFailure
|
||||||
&& result.exceptionOrNull()?.javaClass == SendMsgException::class.java
|
&& result.exceptionOrNull()?.javaClass == SendMsgException::class.java
|
||||||
&& retryCnt > 0) {
|
&& retryCnt > 0) {
|
||||||
|
@ -9,6 +9,7 @@ import com.tencent.qqnt.msg.api.IMsgService
|
|||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
import kotlinx.coroutines.withTimeoutOrNull
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
import kotlinx.serialization.json.JsonArray
|
import kotlinx.serialization.json.JsonArray
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
@ -38,7 +39,11 @@ internal object MessageHelper {
|
|||||||
): Pair<Long, Int> {
|
): Pair<Long, Int> {
|
||||||
val uniseq = generateMsgId(chatType)
|
val uniseq = generateMsgId(chatType)
|
||||||
val msg = messageArrayToMessageElements(chatType, uniseq.second, peerId, decodeCQCode(message)).also {
|
val msg = messageArrayToMessageElements(chatType, uniseq.second, peerId, decodeCQCode(message)).also {
|
||||||
if (it.second.isEmpty() && !it.first) error("消息合成失败,请查看日志或者检查输入。")
|
if (it.second.isEmpty() && !it.first) {
|
||||||
|
error("消息合成失败,请查看日志或者检查输入。")
|
||||||
|
} else if (it.second.isEmpty()) {
|
||||||
|
return System.currentTimeMillis() to 0
|
||||||
|
}
|
||||||
}.second.filter {
|
}.second.filter {
|
||||||
it.elementType != -1
|
it.elementType != -1
|
||||||
} as ArrayList<MsgElement>
|
} as ArrayList<MsgElement>
|
||||||
@ -59,6 +64,12 @@ internal object MessageHelper {
|
|||||||
}.second.filter {
|
}.second.filter {
|
||||||
it.elementType != -1
|
it.elementType != -1
|
||||||
} as ArrayList<MsgElement>
|
} as ArrayList<MsgElement>
|
||||||
|
|
||||||
|
// ActionMsg No Care
|
||||||
|
if (msg.isEmpty()) {
|
||||||
|
return Result.success(System.currentTimeMillis() to 0)
|
||||||
|
}
|
||||||
|
|
||||||
val totalSize = msg.filter {
|
val totalSize = msg.filter {
|
||||||
it.elementType == MsgConstant.KELEMTYPEPIC ||
|
it.elementType == MsgConstant.KELEMTYPEPIC ||
|
||||||
it.elementType == MsgConstant.KELEMTYPEPTT ||
|
it.elementType == MsgConstant.KELEMTYPEPTT ||
|
||||||
@ -67,11 +78,11 @@ internal object MessageHelper {
|
|||||||
(it.picElement?.fileSize ?: 0) + (it.pttElement?.fileSize
|
(it.picElement?.fileSize ?: 0) + (it.pttElement?.fileSize
|
||||||
?: 0) + (it.videoElement?.fileSize ?: 0)
|
?: 0) + (it.videoElement?.fileSize ?: 0)
|
||||||
}.reduceOrNull { a, b -> a + b } ?: 0
|
}.reduceOrNull { a, b -> a + b } ?: 0
|
||||||
|
val estimateTime = (totalSize / (300 * 1024)) * 1000 + 2000
|
||||||
|
|
||||||
val estimateTime = (totalSize / (300 * 1024)) * 1000 + 5000
|
|
||||||
lateinit var sendResultPair: Pair<Long, Int>
|
lateinit var sendResultPair: Pair<Long, Int>
|
||||||
val sendRet = withTimeoutOrNull<Pair<Int, String>>(estimateTime) {
|
val sendRet = withTimeoutOrNull<Pair<Int, String>>(estimateTime) {
|
||||||
suspendCoroutine {
|
suspendCancellableCoroutine {
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
sendResultPair = sendMessageWithoutMsgId(
|
sendResultPair = sendMessageWithoutMsgId(
|
||||||
chatType,
|
chatType,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user