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) } }