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
8117382f
Commit
8117382f
authored
May 09, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs for event intercepting
parent
288c4cf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt
...core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt
+6
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt
...src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt
+4
-1
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/Event.kt
View file @
8117382f
...
@@ -39,12 +39,18 @@ interface Event {
...
@@ -39,12 +39,18 @@ interface Event {
* 事件是否已被拦截.
* 事件是否已被拦截.
*
*
* 所有事件都可以被拦截, 拦截后低优先级的监听器将不会处理到这个事件.
* 所有事件都可以被拦截, 拦截后低优先级的监听器将不会处理到这个事件.
*
* @see intercept 拦截事件
*/
*/
@SinceMirai
(
"1.0.0"
)
@SinceMirai
(
"1.0.0"
)
val
isIntercepted
:
Boolean
val
isIntercepted
:
Boolean
/**
/**
* 拦截这个事件
* 拦截这个事件
*
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
*
* @see [Listener.EventPriority] 查看优先级相关信息
*/
*/
@SinceMirai
(
"1.0.0"
)
@SinceMirai
(
"1.0.0"
)
fun
intercept
()
fun
intercept
()
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscriber.kt
View file @
8117382f
...
@@ -92,6 +92,8 @@ interface Listener<in E : Event> : CompletableJob {
...
@@ -92,6 +92,8 @@ interface Listener<in E : Event> : CompletableJob {
* - 使用 [MONITOR] 优先级的监听器将会被**并行**调用.
* - 使用 [MONITOR] 优先级的监听器将会被**并行**调用.
* - 使用其他优先级的监听器都将会**按顺序**调用.
* - 使用其他优先级的监听器都将会**按顺序**调用.
* 因此一个监听器的挂起可以阻塞事件处理过程而导致低优先级的监听器较晚处理.
* 因此一个监听器的挂起可以阻塞事件处理过程而导致低优先级的监听器较晚处理.
*
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
*/
*/
@SinceMirai
(
"1.0.0"
)
@SinceMirai
(
"1.0.0"
)
enum
class
EventPriority
{
enum
class
EventPriority
{
...
@@ -101,7 +103,8 @@ interface Listener<in E : Event> : CompletableJob {
...
@@ -101,7 +103,8 @@ interface Listener<in E : Event> : CompletableJob {
/**
/**
* 最低的优先级.
* 最低的优先级.
*
*
* 只监听事件而不拦截事件的监听器应使用此监听器.
* 使用此优先级的监听器应遵循约束:
* - 不 [拦截事件][Event.intercept]
*/
*/
MONITOR
;
MONITOR
;
...
...
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