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
8139a4df
Commit
8139a4df
authored
Nov 16, 2019
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid using enum
parent
d5061011
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
32 deletions
+45
-32
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Subscribers.kt
...rc/commonMain/kotlin/net.mamoe.mirai/event/Subscribers.kt
+14
-5
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/internal/MessageDataInternal.kt
...n/net.mamoe.mirai/message/internal/MessageDataInternal.kt
+0
-4
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/OnlineStatus.kt
...c/commonMain/kotlin/net.mamoe.mirai/utils/OnlineStatus.kt
+31
-23
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Subscribers.kt
View file @
8139a4df
...
@@ -5,6 +5,7 @@ package net.mamoe.mirai.event
...
@@ -5,6 +5,7 @@ package net.mamoe.mirai.event
import
net.mamoe.mirai.event.internal.Handler
import
net.mamoe.mirai.event.internal.Handler
import
net.mamoe.mirai.event.internal.Listener
import
net.mamoe.mirai.event.internal.Listener
import
net.mamoe.mirai.event.internal.subscribeInternal
import
net.mamoe.mirai.event.internal.subscribeInternal
import
kotlin.jvm.JvmStatic
import
kotlin.reflect.KClass
import
kotlin.reflect.KClass
/*
/*
...
@@ -14,9 +15,13 @@ import kotlin.reflect.KClass
...
@@ -14,9 +15,13 @@ import kotlin.reflect.KClass
/**
/**
* 订阅者的状态
* 订阅者的状态
*/
*/
enum
class
ListeningStatus
{
inline
class
ListeningStatus
(
inline
val
listening
:
Boolean
)
{
LISTENING
,
companion
object
{
STOPPED
@JvmStatic
val
LISTENING
=
ListeningStatus
(
true
)
@JvmStatic
val
STOPPED
=
ListeningStatus
(
false
)
}
}
}
...
@@ -141,13 +146,17 @@ class ListenerBuilder<out E : Subscribable>(
...
@@ -141,13 +146,17 @@ class ListenerBuilder<out E : Subscribable>(
suspend
inline
fun
always
(
noinline
listener
:
suspend
(
E
)
->
Unit
)
=
handler
{
listener
(
it
);
ListeningStatus
.
LISTENING
}
suspend
inline
fun
always
(
noinline
listener
:
suspend
(
E
)
->
Unit
)
=
handler
{
listener
(
it
);
ListeningStatus
.
LISTENING
}
suspend
inline
fun
<
T
>
until
(
until
:
T
,
noinline
listener
:
suspend
(
E
)
->
T
)
=
handler
{
if
(
listener
(
it
)
===
until
)
ListeningStatus
.
STOPPED
else
ListeningStatus
.
LISTENING
}
suspend
inline
fun
<
T
>
until
(
until
:
T
,
noinline
listener
:
suspend
(
E
)
->
T
)
=
handler
{
if
(
listener
(
it
)
===
until
)
ListeningStatus
.
STOPPED
else
ListeningStatus
.
LISTENING
}
suspend
inline
fun
untilFalse
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
until
(
false
,
listener
)
suspend
inline
fun
untilFalse
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
until
(
false
,
listener
)
suspend
inline
fun
untilTrue
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
until
(
true
,
listener
)
suspend
inline
fun
untilTrue
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
until
(
true
,
listener
)
suspend
inline
fun
untilNull
(
noinline
listener
:
suspend
(
E
)
->
Any
?)
=
until
(
null
,
listener
)
suspend
inline
fun
untilNull
(
noinline
listener
:
suspend
(
E
)
->
Any
?)
=
until
(
null
,
listener
)
suspend
inline
fun
<
T
>
`while`
(
until
:
T
,
noinline
listener
:
suspend
(
E
)
->
T
)
=
handler
{
if
(
listener
(
it
)
!==
until
)
ListeningStatus
.
STOPPED
else
ListeningStatus
.
LISTENING
}
suspend
inline
fun
<
T
>
`while`
(
until
:
T
,
noinline
listener
:
suspend
(
E
)
->
T
)
=
handler
{
if
(
listener
(
it
)
!==
until
)
ListeningStatus
.
STOPPED
else
ListeningStatus
.
LISTENING
}
suspend
inline
fun
whileFalse
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
`while`
(
false
,
listener
)
suspend
inline
fun
whileFalse
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
`while`
(
false
,
listener
)
suspend
inline
fun
whileTrue
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
`while`
(
true
,
listener
)
suspend
inline
fun
whileTrue
(
noinline
listener
:
suspend
(
E
)
->
Boolean
)
=
`while`
(
true
,
listener
)
suspend
inline
fun
whileNull
(
noinline
listener
:
suspend
(
E
)
->
Any
?)
=
`while`
(
null
,
listener
)
suspend
inline
fun
whileNull
(
noinline
listener
:
suspend
(
E
)
->
Any
?)
=
`while`
(
null
,
listener
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/internal/MessageDataInternal.kt
View file @
8139a4df
...
@@ -55,10 +55,6 @@ internal fun IoBuffer.parseMessageImage0x06(): Image {
...
@@ -55,10 +55,6 @@ internal fun IoBuffer.parseMessageImage0x06(): Image {
// 00 04 00 00 00 2E 1A 00 04 00 00 00 2E FF
// 00 04 00 00 00 2E 1A 00 04 00 00 00 2E FF
// 00 63 16 20 20 39 39 31 30 20 38 38 31 43 42 20 20 20 20 20 20 20 36 36 38 65 35 43 36 38 45 36 42 44 32 46 35 38 34 31 42 30 39 37 39 45 37 46 32 35 34 33 38 38 31 33 43 33 2E 6A 70 67 66 2F 32 65 37 61 65 33 36 66 2D 61 39 31 63 2D 34 31 32 39 2D 62 61 34 32 2D 37 65 30 31 32 39 37 37 35 63 63 38 41
// 00 63 16 20 20 39 39 31 30 20 38 38 31 43 42 20 20 20 20 20 20 20 36 36 38 65 35 43 36 38 45 36 42 44 32 46 35 38 34 31 42 30 39 37 39 45 37 46 32 35 34 33 38 38 31 33 43 33 2E 6A 70 67 66 2F 32 65 37 61 65 33 36 66 2D 61 39 31 63 2D 34 31 32 39 2D 62 61 34 32 2D 37 65 30 31 32 39 37 37 35 63 63 38 41
fun
main
()
{
println
(
"."
.
repeat
(
1000
))
}
internal
fun
IoBuffer
.
parseMessageImage0x03
():
Image
{
internal
fun
IoBuffer
.
parseMessageImage0x03
():
Image
{
discardExact
(
1
)
discardExact
(
1
)
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/OnlineStatus.kt
View file @
8139a4df
...
@@ -2,43 +2,51 @@
...
@@ -2,43 +2,51 @@
package
net.mamoe.mirai.utils
package
net.mamoe.mirai.utils
import
kotlin.jvm.JvmStatic
/**
/**
* QQ 在线状态
* QQ 在线状态
*
*
* @author Him188moe
* @author Him188moe
* @see net.mamoe.mirai.network.protocol.tim.packet.login.ChangeOnlineStatusPacket
* @see net.mamoe.mirai.network.protocol.tim.packet.login.ChangeOnlineStatusPacket
*/
*/
enum
class
OnlineStatus
(
inline
class
OnlineStatus
(
val
id
:
UByte
//1 ub
yte
inline
val
id
:
UB
yte
)
{
)
{
/**
companion
object
{
* 我在线上
/**
*/
* 我在线上
ONLINE
(
0
x0Au
),
*/
@JvmStatic
val
ONLINE
=
OnlineStatus
(
0
x0Au
)
/**
/**
* 忙碌
* 忙碌
*/
*/
BUSY
(
0
x32u
),
@JvmStatic
val
BUSY
=
OnlineStatus
(
0
x32u
)
/**
/**
* 离线 ? 也可能是被删好友 TODO confirm that
* 离线 ? 也可能是被删好友 TODO confirm that
*/
*/
OFFLINE
(
0
x02u
),
@JvmStatic
val
OFFLINE
=
OnlineStatus
(
0
x02u
)
UNKNOWN1
(
0
x20u
),
@JvmStatic
UNKNOWN2
(
0
x46u
),
val
UNKNOWN1
=
OnlineStatus
(
0
x20u
)
UNKNOWN3
(
0
x14u
),
@JvmStatic
UNKNOWN4
(
0
xC9u
),
val
UNKNOWN2
=
OnlineStatus
(
0
x46u
)
UNKNOWN5
(
0
x1Eu
),
@JvmStatic
;
val
UNKNOWN3
=
OnlineStatus
(
0
x14u
)
@JvmStatic
val
UNKNOWN4
=
OnlineStatus
(
0
xC9u
)
@JvmStatic
val
UNKNOWN5
=
OnlineStatus
(
0
x1Eu
)
}
// TODO: 2019/10/29 what is 0x20u
// TODO: 2019/10/29 what is 0x20u
// TODO: 2019/11/11 what is 0x46u
// TODO: 2019/11/11 what is 0x46u
// TODO: 2019/11/11 what is 0x14u
// TODO: 2019/11/11 what is 0x14u
// TODO: 2019/11/11 0xC9u
// TODO: 2019/11/11 0xC9u
// TODO: 2019/11/11 0x1Eu
// TODO: 2019/11/11 0x1Eu
companion
object
{
fun
ofId
(
id
:
UByte
):
OnlineStatus
?
=
values
().
firstOrNull
{
it
.
id
==
id
}
}
}
}
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