Last change
on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago |
split group project and individual project into two separate folders
|
-
Property mode
set to
100644
|
File size:
841 bytes
|
Line | |
---|
1 | package mk.ukim.finki.busngobackend.api
|
---|
2 |
|
---|
3 | import org.springframework.messaging.handler.annotation.MessageMapping
|
---|
4 | import org.springframework.messaging.handler.annotation.Payload
|
---|
5 | import org.springframework.messaging.handler.annotation.SendTo
|
---|
6 | import org.springframework.messaging.simp.SimpMessageHeaderAccessor
|
---|
7 | import org.springframework.web.bind.annotation.RestController
|
---|
8 |
|
---|
9 | @RestController
|
---|
10 | class ChatController {
|
---|
11 | @MessageMapping("/chat.sendMessage")
|
---|
12 | @SendTo("/topic/public")
|
---|
13 | fun sendMessage(
|
---|
14 | @Payload message: String,
|
---|
15 | ): String = message
|
---|
16 |
|
---|
17 | @MessageMapping("/chat.addUser")
|
---|
18 | @SendTo("/topic/public")
|
---|
19 | fun addUser(
|
---|
20 | @Payload message: String,
|
---|
21 | headerAccessor: SimpMessageHeaderAccessor,
|
---|
22 | ): String {
|
---|
23 | headerAccessor.sessionAttributes?.put("username", message)
|
---|
24 | return message
|
---|
25 | }
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.