Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
1f7bc4e5
Commit
1f7bc4e5
authored
Mar 31, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #178
parent
03d477ab
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
21 deletions
+73
-21
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/jce/JceDecoder.kt
.../mamoe/mirai/qqandroid/io/serialization/jce/JceDecoder.kt
+6
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/jce/JceInput.kt
...et/mamoe/mirai/qqandroid/io/serialization/jce/JceInput.kt
+1
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/utils.kt
...otlin/net/mamoe/mirai/qqandroid/io/serialization/utils.kt
+1
-0
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
...moe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
+4
-4
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/TroopManagement.kt
...qqandroid/network/protocol/packet/chat/TroopManagement.kt
+0
-1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendList.kt
...irai/qqandroid/network/protocol/packet/list/FriendList.kt
+0
-2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/ConfigPushSvc.kt
.../qqandroid/network/protocol/packet/login/ConfigPushSvc.kt
+38
-5
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
...onMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
+23
-6
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/jce/JceDecoder.kt
View file @
1f7bc4e5
...
@@ -291,10 +291,14 @@ internal class JceDecoder(
...
@@ -291,10 +291,14 @@ internal class JceDecoder(
}
}
override
fun
decodeTaggedInt
(
tag
:
JceTag
):
Int
=
override
fun
decodeTaggedInt
(
tag
:
JceTag
):
Int
=
jce
.
skipToHeadAndUseIfPossibleOrFail
(
tag
.
id
)
{
jce
.
readJceIntValue
(
it
)
}
kotlin
.
runCatching
{
jce
.
skipToHeadAndUseIfPossibleOrFail
(
tag
.
id
)
{
jce
.
readJceIntValue
(
it
)
}
}.
getOrElse
{
throw
IllegalStateException
(
"$tag"
,
it
)
}
override
fun
decodeTaggedByte
(
tag
:
JceTag
):
Byte
=
override
fun
decodeTaggedByte
(
tag
:
JceTag
):
Byte
=
jce
.
skipToHeadAndUseIfPossibleOrFail
(
tag
.
id
)
{
jce
.
readJceByteValue
(
it
)
}
kotlin
.
runCatching
{
jce
.
skipToHeadAndUseIfPossibleOrFail
(
tag
.
id
)
{
jce
.
readJceByteValue
(
it
)
}
}.
getOrElse
{
throw
IllegalStateException
(
"$tag"
,
it
)
}
override
fun
decodeTaggedBoolean
(
tag
:
JceTag
):
Boolean
=
override
fun
decodeTaggedBoolean
(
tag
:
JceTag
):
Boolean
=
jce
.
skipToHeadAndUseIfPossibleOrFail
(
tag
.
id
)
{
jce
.
readJceBooleanValue
(
it
)
}
jce
.
skipToHeadAndUseIfPossibleOrFail
(
tag
.
id
)
{
jce
.
readJceBooleanValue
(
it
)
}
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/jce/JceInput.kt
View file @
1f7bc4e5
...
@@ -121,7 +121,7 @@ internal class JceInput(
...
@@ -121,7 +121,7 @@ internal class JceInput(
when
(
type
)
{
when
(
type
)
{
Jce
.
BYTE
->
this
.
input
.
discardExact
(
1
)
Jce
.
BYTE
->
this
.
input
.
discardExact
(
1
)
Jce
.
SHORT
->
this
.
input
.
discardExact
(
2
)
Jce
.
SHORT
->
this
.
input
.
discardExact
(
2
)
Jce
.
INT
->
println
(
"readInt="
+
this
.
input
.
readInt
()
)
Jce
.
INT
->
this
.
input
.
discardExact
(
4
)
Jce
.
LONG
->
this
.
input
.
discardExact
(
8
)
Jce
.
LONG
->
this
.
input
.
discardExact
(
8
)
Jce
.
FLOAT
->
this
.
input
.
discardExact
(
4
)
Jce
.
FLOAT
->
this
.
input
.
discardExact
(
4
)
Jce
.
DOUBLE
->
this
.
input
.
discardExact
(
8
)
Jce
.
DOUBLE
->
this
.
input
.
discardExact
(
8
)
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/io/serialization/utils.kt
View file @
1f7bc4e5
...
@@ -27,6 +27,7 @@ import net.mamoe.mirai.utils.firstValue
...
@@ -27,6 +27,7 @@ import net.mamoe.mirai.utils.firstValue
import
net.mamoe.mirai.utils.io.read
import
net.mamoe.mirai.utils.io.read
import
net.mamoe.mirai.qqandroid.utils.io.readPacketExact
import
net.mamoe.mirai.qqandroid.utils.io.readPacketExact
import
net.mamoe.mirai.utils.io.toReadPacket
import
net.mamoe.mirai.utils.io.toReadPacket
import
net.mamoe.mirai.utils.io.toUHexString
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmMultifileClass
import
kotlin.jvm.JvmName
import
kotlin.jvm.JvmName
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt
View file @
1f7bc4e5
...
@@ -36,11 +36,11 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
...
@@ -36,11 +36,11 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.list.FriendList
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.Heartbeat
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.Heartbeat
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.StatSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.StatSvc
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.WtLogin
import
net.mamoe.mirai.qqandroid.network.protocol.packet.login.WtLogin
import
net.mamoe.mirai.qqandroid.utils.io.readPacketExact
import
net.mamoe.mirai.qqandroid.utils.io.useBytes
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.*
import
net.mamoe.mirai.utils.io.ByteArrayPool
import
net.mamoe.mirai.utils.io.ByteArrayPool
import
net.mamoe.mirai.utils.io.PlatformSocket
import
net.mamoe.mirai.utils.io.PlatformSocket
import
net.mamoe.mirai.qqandroid.utils.io.readPacketExact
import
net.mamoe.mirai.qqandroid.utils.io.useBytes
import
kotlin.coroutines.CoroutineContext
import
kotlin.coroutines.CoroutineContext
import
kotlin.jvm.Volatile
import
kotlin.jvm.Volatile
import
kotlin.time.ExperimentalTime
import
kotlin.time.ExperimentalTime
...
@@ -117,9 +117,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
...
@@ -117,9 +117,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
channel
=
PlatformSocket
()
channel
=
PlatformSocket
()
// TODO: 2020/2/14 连接多个服务器, #52
// TODO: 2020/2/14 连接多个服务器, #52
withTimeoutOrNull
(
3000
)
{
withTimeoutOrNull
(
3000
)
{
channel
.
connect
(
"11
3.96.13.208
"
,
8080
)
channel
.
connect
(
"11
4.221.144.22
"
,
8080
)
}
?:
error
(
"timeout connecting server"
)
}
?:
error
(
"timeout connecting server"
)
logger
.
info
(
"Connected to server 11
3.96.13.208
:8080"
)
logger
.
info
(
"Connected to server 11
4.221.144.22
:8080"
)
startPacketReceiverJobOrKill
(
CancellationException
(
"relogin"
,
cause
))
startPacketReceiverJobOrKill
(
CancellationException
(
"relogin"
,
cause
))
var
response
:
WtLogin
.
Login
.
LoginPacketResponse
=
WtLogin
.
Login
.
SubCommand9
(
bot
.
client
).
sendAndExpect
()
var
response
:
WtLogin
.
Login
.
LoginPacketResponse
=
WtLogin
.
Login
.
SubCommand9
(
bot
.
client
).
sendAndExpect
()
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/TroopManagement.kt
View file @
1f7bc4e5
...
@@ -397,7 +397,6 @@ internal class TroopManagement {
...
@@ -397,7 +397,6 @@ internal class TroopManagement {
sServantName
=
"mqq.IMService.FriendListServiceServantObj"
,
sServantName
=
"mqq.IMService.FriendListServiceServantObj"
,
iVersion
=
3
,
iVersion
=
3
,
cPacketType
=
0
x00
,
cPacketType
=
0
x00
,
iMessageType
=
0
x00000
,
iRequestId
=
client
.
nextRequestPacketRequestId
(),
iRequestId
=
client
.
nextRequestPacketRequestId
(),
sBuffer
=
jceRequestSBuffer
(
sBuffer
=
jceRequestSBuffer
(
"MGCREQ"
,
"MGCREQ"
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendList.kt
View file @
1f7bc4e5
...
@@ -101,7 +101,6 @@ internal class FriendList {
...
@@ -101,7 +101,6 @@ internal class FriendList {
sServantName
=
"mqq.IMService.FriendListServiceServantObj"
,
sServantName
=
"mqq.IMService.FriendListServiceServantObj"
,
iVersion
=
3
,
iVersion
=
3
,
cPacketType
=
0
x00
,
cPacketType
=
0
x00
,
iMessageType
=
0
x00000
,
iRequestId
=
client
.
nextRequestPacketRequestId
(),
iRequestId
=
client
.
nextRequestPacketRequestId
(),
sBuffer
=
jceRequestSBuffer
(
sBuffer
=
jceRequestSBuffer
(
"GetTroopListReqV2Simplify"
,
"GetTroopListReqV2Simplify"
,
...
@@ -156,7 +155,6 @@ internal class FriendList {
...
@@ -156,7 +155,6 @@ internal class FriendList {
sServantName
=
"mqq.IMService.FriendListServiceServantObj"
,
sServantName
=
"mqq.IMService.FriendListServiceServantObj"
,
iVersion
=
3
,
iVersion
=
3
,
cPacketType
=
0
x003
,
cPacketType
=
0
x003
,
iMessageType
=
0
x00000
,
iRequestId
=
1921334514
,
iRequestId
=
1921334514
,
sBuffer
=
jceRequestSBuffer
(
sBuffer
=
jceRequestSBuffer
(
"FL"
,
"FL"
,
...
...
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/login/ConfigPushSvc.kt
View file @
1f7bc4e5
This diff is collapsed.
Click to expand it.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
View file @
1f7bc4e5
...
@@ -191,7 +191,11 @@ open class LockFreeLinkedList<E> {
...
@@ -191,7 +191,11 @@ open class LockFreeLinkedList<E> {
return
current
.
nodeValue
return
current
.
nodeValue
if
(
current
.
nextNode
===
tail
)
{
if
(
current
.
nextNode
===
tail
)
{
if
(
current
.
compareAndSetNextNodeRef
(
tail
,
node
))
{
// ensure only one attempt can put the lazyNode in
if
(
current
.
compareAndSetNextNodeRef
(
tail
,
node
)
)
{
// ensure only one attempt can put the lazyNode in
return
node
.
nodeValue
return
node
.
nodeValue
}
}
}
}
...
@@ -202,7 +206,10 @@ open class LockFreeLinkedList<E> {
...
@@ -202,7 +206,10 @@ open class LockFreeLinkedList<E> {
}
}
@PublishedApi
// limitation by atomicfu
@PublishedApi
// limitation by atomicfu
internal
fun
<
E
>
LockFreeLinkedListNode
<
E
>.
compareAndSetNextNodeRef
(
expect
:
LockFreeLinkedListNode
<
E
>,
update
:
LockFreeLinkedListNode
<
E
>)
=
internal
fun
<
E
>
LockFreeLinkedListNode
<
E
>.
compareAndSetNextNodeRef
(
expect
:
LockFreeLinkedListNode
<
E
>,
update
:
LockFreeLinkedListNode
<
E
>
)
=
this
.
nextNodeRef
.
compareAndSet
(
expect
,
update
)
this
.
nextNodeRef
.
compareAndSet
(
expect
,
update
)
override
fun
toString
():
String
=
"["
+
asSequence
().
joinToString
()
+
"]"
override
fun
toString
():
String
=
"["
+
asSequence
().
joinToString
()
+
"]"
...
@@ -277,7 +284,10 @@ open class LockFreeLinkedList<E> {
...
@@ -277,7 +284,10 @@ open class LockFreeLinkedList<E> {
/**
/**
* 动态计算的大小
* 动态计算的大小
*/
*/
val
size
:
Int
get
()
=
head
.
countChildIterate
<
LockFreeLinkedListNode
<
E
>>({
it
.
nextNode
},
{
it
!
is
Tail
})
-
1
// empty head is always included
val
size
:
Int
get
()
=
head
.
countChildIterate
<
LockFreeLinkedListNode
<
E
>>(
{
it
.
nextNode
},
{
it
!
is
Tail
})
-
1
// empty head is always included
open
operator
fun
contains
(
element
:
E
):
Boolean
{
open
operator
fun
contains
(
element
:
E
):
Boolean
{
forEach
{
if
(
it
==
element
)
return
true
}
forEach
{
if
(
it
==
element
)
return
true
}
...
@@ -312,10 +322,13 @@ open class LockFreeLinkedList<E> {
...
@@ -312,10 +322,13 @@ open class LockFreeLinkedList<E> {
open
fun
clear
(
onEach
:
((
E
)
->
Unit
)?
=
null
)
{
open
fun
clear
(
onEach
:
((
E
)
->
Unit
)?
=
null
)
{
val
first
=
head
.
nextNode
val
first
=
head
.
nextNode
head
.
nextNode
=
tail
head
.
nextNode
=
tail
first
.
childIterateReturnFirstUnsatisfying
({
first
.
childIterateReturnFirstUnsatisfying
(
lambda
@
{
val
n
=
it
.
nextNode
val
n
=
it
.
nextNode
it
.
nextNode
=
tail
it
.
nextNode
=
tail
it
.
removed
.
value
=
true
it
.
removed
.
value
=
true
if
(
n
===
tail
)
{
return
@
lambda
n
}
onEach
?.
invoke
(
n
.
nodeValue
)
onEach
?.
invoke
(
n
.
nodeValue
)
n
n
},
{
it
!==
tail
})
// clear the link structure, help GC.
},
{
it
!==
tail
})
// clear the link structure, help GC.
...
@@ -644,14 +657,18 @@ open class LockFreeLinkedList<E> {
...
@@ -644,14 +657,18 @@ open class LockFreeLinkedList<E> {
// region internal
// region internal
@Suppress
(
"NOTHING_TO_INLINE"
)
@Suppress
(
"NOTHING_TO_INLINE"
)
private
inline
fun
<
E
>
E
.
asNode
(
nextNode
:
LockFreeLinkedListNode
<
E
>):
LockFreeLinkedListNode
<
E
>
=
LockFreeLinkedListNode
(
nextNode
,
this
)
private
inline
fun
<
E
>
E
.
asNode
(
nextNode
:
LockFreeLinkedListNode
<
E
>):
LockFreeLinkedListNode
<
E
>
=
LockFreeLinkedListNode
(
nextNode
,
this
)
/**
/**
* Self-iterate using the [iterator], until [mustBeTrue] returns `false`.
* Self-iterate using the [iterator], until [mustBeTrue] returns `false`.
* Returns the element at the last time when the [mustBeTrue] returns `true`
* Returns the element at the last time when the [mustBeTrue] returns `true`
*/
*/
@PublishedApi
@PublishedApi
internal
inline
fun
<
N
:
LockFreeLinkedListNode
<
*
>>
N
.
childIterateReturnsLastSatisfying
(
iterator
:
(
N
)
->
N
,
mustBeTrue
:
(
N
)
->
Boolean
):
N
{
internal
inline
fun
<
N
:
LockFreeLinkedListNode
<
*
>>
N
.
childIterateReturnsLastSatisfying
(
iterator
:
(
N
)
->
N
,
mustBeTrue
:
(
N
)
->
Boolean
):
N
{
if
(!
mustBeTrue
(
this
))
return
this
if
(!
mustBeTrue
(
this
))
return
this
var
value
:
N
=
this
var
value
:
N
=
this
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment