-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from ForteScarlet/v3-dev-reactiveSupport
SimpleEventResult的content支持解析并收集reactive等响应式结果
- Loading branch information
Showing
15 changed files
with
356 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ot-core-spring-boot-starter/src/test/kotlin/love/forte/test/webflux/WebfluxApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package love.forte.test.webflux | ||
|
||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.flow | ||
import love.forte.simboot.annotation.Listener | ||
import love.forte.simboot.autoconfigure.EnableSimbot | ||
import love.forte.simbot.PriorityConstant | ||
import love.forte.simbot.event.EventProcessingContext | ||
import love.forte.simbot.event.FriendMessageEvent | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
import org.springframework.stereotype.Controller | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.ResponseBody | ||
import reactor.core.publisher.Mono | ||
|
||
|
||
/** | ||
* | ||
* @author ForteScarlet | ||
*/ | ||
@SpringBootApplication | ||
@EnableSimbot | ||
open class WebfluxApplication | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<WebfluxApplication>(*args) | ||
} | ||
|
||
|
||
@Controller | ||
open class MyController { | ||
|
||
@ResponseBody | ||
@GetMapping("/hi") | ||
suspend fun hello(): Map<String, Any> { | ||
delay(100) | ||
return mapOf("name" to "forte", "age" to 10) | ||
} | ||
|
||
@Listener | ||
suspend fun FriendMessageEvent.myListen1() = flow { | ||
emit(1) | ||
bot.logger.info("emit: {}", 1) | ||
delay(2000) | ||
emit(2) | ||
bot.logger.info("emit: {}", 2) | ||
} | ||
|
||
@Listener | ||
suspend fun FriendMessageEvent.myListen2() = Mono.just(3) | ||
|
||
@Listener(priority = PriorityConstant.LAST) | ||
suspend fun FriendMessageEvent.myListen3(context: EventProcessingContext) { | ||
context.results.forEach { | ||
friend().send(it.toString()) | ||
} | ||
} | ||
|
||
} |
12 changes: 0 additions & 12 deletions
12
boots/simboot-core-spring-boot-starter/src/test/resources/simbot-bots/A.bot
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
boots/simboot-core-spring-boot-starter/src/test/resources/simbot-bots/B.bot
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.