You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
683 B
20 lines
683 B
package com.example.demo.controller
|
|
|
|
import com.example.demo.service.UserService
|
|
import kotlinx.coroutines.coroutineScope
|
|
import org.springframework.messaging.handler.annotation.DestinationVariable
|
|
import org.springframework.messaging.handler.annotation.MessageMapping
|
|
import org.springframework.stereotype.Component
|
|
|
|
@Component
|
|
class RsocketDemoController(private val userService: UserService) {
|
|
@MessageMapping("messages.findAll")
|
|
suspend fun all() = coroutineScope {
|
|
userService.getAllMessages()
|
|
}
|
|
|
|
@MessageMapping("users.{name}")
|
|
suspend fun getUser(@DestinationVariable name: String) = coroutineScope {
|
|
userService.getUserByName(name)
|
|
}
|
|
}
|