mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: fix #61
This commit is contained in:
parent
2af8d6d817
commit
98c6316e23
@ -11,6 +11,7 @@ import kotlinx.coroutines.DelicateCoroutinesApi
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
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 moe.fuqiuluo.proto.protobufOf
|
import moe.fuqiuluo.proto.protobufOf
|
||||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||||
@ -37,9 +38,9 @@ internal abstract class BaseSvc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun sendOidbAW(cmd: String, cmdId: Int, serviceId: Int, data: ByteArray, trpc: Boolean = false, timeout: Long = 5000L): ByteArray? {
|
suspend fun sendOidbAW(cmd: String, cmdId: Int, serviceId: Int, data: ByteArray, trpc: Boolean = false, timeout: Long = 5000L): ByteArray? {
|
||||||
return withTimeoutOrNull(timeout) {
|
|
||||||
suspendCoroutine { continuation ->
|
|
||||||
val seq = MsfCore.getNextSeq()
|
val seq = MsfCore.getNextSeq()
|
||||||
|
return withTimeoutOrNull(timeout) {
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
GlobalScope.launch(Dispatchers.Default) {
|
GlobalScope.launch(Dispatchers.Default) {
|
||||||
DynamicReceiver.register(IPCRequest(cmd, seq) {
|
DynamicReceiver.register(IPCRequest(cmd, seq) {
|
||||||
val buffer = it.getByteArrayExtra("buffer")!!
|
val buffer = it.getByteArrayExtra("buffer")!!
|
||||||
@ -49,13 +50,16 @@ internal abstract class BaseSvc {
|
|||||||
if (trpc) sendTrpcOidb(cmd, cmdId, serviceId, data, seq)
|
if (trpc) sendTrpcOidb(cmd, cmdId, serviceId, data, seq)
|
||||||
else sendOidb(cmd, cmdId, serviceId, data, seq)
|
else sendOidb(cmd, cmdId, serviceId, data, seq)
|
||||||
}
|
}
|
||||||
|
}.also {
|
||||||
|
if (it == null)
|
||||||
|
DynamicReceiver.unregister(seq)
|
||||||
}?.copyOf()
|
}?.copyOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun sendBufferAW(cmd: String, isPb: Boolean, data: ByteArray, timeout: Long = 5000L): ByteArray? {
|
suspend fun sendBufferAW(cmd: String, isPb: Boolean, data: ByteArray, timeout: Long = 5000L): ByteArray? {
|
||||||
return withTimeoutOrNull<ByteArray?>(timeout) {
|
|
||||||
suspendCoroutine { continuation ->
|
|
||||||
val seq = MsfCore.getNextSeq()
|
val seq = MsfCore.getNextSeq()
|
||||||
|
return withTimeoutOrNull<ByteArray?>(timeout) {
|
||||||
|
suspendCancellableCoroutine { continuation ->
|
||||||
GlobalScope.launch(Dispatchers.Default) {
|
GlobalScope.launch(Dispatchers.Default) {
|
||||||
DynamicReceiver.register(IPCRequest(cmd, seq) {
|
DynamicReceiver.register(IPCRequest(cmd, seq) {
|
||||||
val buffer = it.getByteArrayExtra("buffer")!!
|
val buffer = it.getByteArrayExtra("buffer")!!
|
||||||
@ -64,6 +68,9 @@ internal abstract class BaseSvc {
|
|||||||
sendBuffer(cmd, isPb, data, seq)
|
sendBuffer(cmd, isPb, data, seq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.also {
|
||||||
|
if (it == null)
|
||||||
|
DynamicReceiver.unregister(seq)
|
||||||
}?.copyOf()
|
}?.copyOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,24 +63,30 @@ internal object RichProtoSvc: BaseSvc() {
|
|||||||
suspend fun getC2CFileDownUrl(
|
suspend fun getC2CFileDownUrl(
|
||||||
fileId: String,
|
fileId: String,
|
||||||
subId: String,
|
subId: String,
|
||||||
|
retryCnt: Int = 0
|
||||||
): String {
|
): String {
|
||||||
val uid = ContactHelper.getUidByUinAsync(app.currentUin.toLong())
|
val buffer = sendOidbAW("OidbSvc.0xe37_1200", 3639, 1200, protobufOf(
|
||||||
val buffer = sendOidbAW("OidbSvcTrpcTcp.0xe37_1200", 3639, 1200, protobufOf(
|
|
||||||
1 to 1200,
|
1 to 1200,
|
||||||
2 to 1 /* QRoute.api(IAudioHelperApi::class.java).genDebugSeq().toInt() */, /* seq */
|
2 to 1 /* QRoute.api(IAudioHelperApi::class.java).genDebugSeq().toInt() */, /* seq */
|
||||||
14 to mapOf(
|
14 to mapOf(
|
||||||
10 to uid,
|
10 to app.longAccountUin,
|
||||||
20 to fileId,
|
20 to fileId,
|
||||||
30 to 2, /* ver */
|
30 to 2, /* ver */
|
||||||
60 to subId,
|
60 to subId,
|
||||||
601 to 0
|
601 to 0
|
||||||
),
|
),
|
||||||
101 to 3,
|
101 to 3, // uint32_business_id
|
||||||
102 to 104, /* client_type */
|
102 to 104, /* client_type */
|
||||||
200 to 1, /* url_type */
|
200 to 1, /* uint32_flag_support_mediaplatform */
|
||||||
99999 to 90200 to 1
|
99999 to mapOf(
|
||||||
).toByteArray(), trpc = true)
|
90200 to 1 // uint32_download_url_type
|
||||||
|
)
|
||||||
|
).toByteArray())
|
||||||
|
|
||||||
if (buffer == null) {
|
if (buffer == null) {
|
||||||
|
if (retryCnt < 3) {
|
||||||
|
return getC2CFileDownUrl(fileId, subId, retryCnt + 1)
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
} else {
|
} else {
|
||||||
val body = oidb_sso.OIDBSSOPkg()
|
val body = oidb_sso.OIDBSSOPkg()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user