Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import likelion.mlb.backendProject.domain.chat.entity.ChatMessage;
import likelion.mlb.backendProject.domain.chat.service.ChatMessageService;
import likelion.mlb.backendProject.global.security.dto.CustomUserDetails;
import org.springframework.transaction.annotation.Transactional;

@Controller
@RequiredArgsConstructor
Expand All @@ -26,6 +27,7 @@ public class ChatMessagingController {
private final ChatRedisPublisher chatRedisPublisher;


@Transactional
@MessageMapping("/chat/{roomId}/send")
public void send(@DestinationVariable UUID roomId,
ChatSendRequest req,
Expand All @@ -47,26 +49,18 @@ public void send(@DestinationVariable UUID roomId,
System.out.println("------------/chat/{roomId}/send 시작 ");

// 안전장치: 메시지의 roomId는 URL의 roomId로 강제
//ChatMessage saved = chatMessageService.saveUserMessage(roomId, userId, req.getContent());

// Map<String, Object> payload = Map.of(
// "id", saved.getId().toString(),
// "chatRoomId", roomId.toString(),
// "type", saved.getMessageType().name(),
// "content", saved.getContent(),
// "userId", userId != null ? userId.toString() : null,
// "createdAt", saved.getCreatedAt().toString()
// );
ChatMessage saved = chatMessageService.saveUserMessage(roomId, userId, req.getContent());

Map<String, Object> payload = Map.of(
"id", 2,
"id", saved.getId().toString(),
"chatRoomId", roomId.toString(),
"type", "USER",
"content", "웹소켓 테스트",
"type", saved.getMessageType().name(),
"content", saved.getContent(),
"userId", userId != null ? userId.toString() : null,
"createdAt", "ㅇㅇㅇ"
"createdAt", saved.getCreatedAt().toString()
);


//System.out.println("------------받은메세지 payload"+payload.get(0).toString());

System.out.println("------------받은메세지"+req.getContent());
Expand Down