@@ -42,15 +42,7 @@ public class EncryptServiceContext @MiraiInternalApi constructor(
42
42
/* *
43
43
* @since 2.15.0
44
44
*/
45
- public interface EncryptService : BaseService {
46
- /* * service per bot */
47
- public fun attachToBot (context : EncryptServiceContext , serviceSubScope : CoroutineScope ): EncryptService {
48
- /* cleanup:
49
- serviceSubScope.coroutineContext.job.invokeOnCompletion { }
50
- */
51
- return this
52
- }
53
-
45
+ public interface EncryptService {
54
46
public fun initialize (context : EncryptServiceContext )
55
47
56
48
/* *
@@ -91,8 +83,20 @@ public interface EncryptService : BaseService {
91
83
public suspend fun sendMessage (remark : String , commandName : String , uin : Long , data : ByteArray ): ChannelResult ?
92
84
}
93
85
86
+ // net.mamoe.mirai.internal.spi.EncryptService$Factory
87
+ public interface Factory : BaseService {
88
+
89
+ /*
90
+ * cleanup:
91
+ * serviceSubScope.coroutineContext.job.invokeOnCompletion { }
92
+ */
93
+ public fun createForBot (context : EncryptServiceContext , serviceSubScope : CoroutineScope ): EncryptService
94
+ }
95
+
96
+
94
97
public companion object {
95
- private val loader = SpiServiceLoader (EncryptService ::class )
98
+
99
+ private val loader = SpiServiceLoader (Factory ::class )
96
100
97
101
private val warningAlert: Unit by lazy {
98
102
val log = MiraiLogger .Factory .create(EncryptService ::class , " EncryptService.alert" )
@@ -113,15 +117,10 @@ public interface EncryptService : BaseService {
113
117
114
118
}
115
119
116
- @GlobalEncryptServiceUsage
117
- internal val instance: EncryptService ?
120
+ internal val factory: Factory ?
118
121
get() {
119
122
warningAlert
120
123
return loader.service
121
124
}
122
125
}
123
-
124
126
}
125
-
126
- @RequiresOptIn(message = " Global encrypt service used" , level = RequiresOptIn .Level .ERROR )
127
- internal annotation class GlobalEncryptServiceUsage
0 commit comments