-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature: 채팅방 참가/나가기 시 SYSTEM 해당하는 메시지를 표시합니다.
- Loading branch information
Showing
11 changed files
with
148 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { MessageResponseDto } from "../types/MessageResponseDto"; | ||
|
||
interface ChatMessageItemProps { | ||
message: MessageResponseDto; | ||
isMine: boolean; | ||
} | ||
|
||
export default function ChatMessageItem({ | ||
message, | ||
isMine, | ||
}: ChatMessageItemProps) { | ||
return ( | ||
<div | ||
className={`flex flex-col gap-1 ${isMine ? "items-end" : "items-start"}`} | ||
> | ||
<span className="text-sm text-neutral-400">{message.nickname}</span> | ||
<div | ||
className={`px-4 py-3 my-1 rounded-xl w-fit shadow-md ${ | ||
isMine ? "bg-blue-600 text-white self-end" : "bg-white self-start" | ||
}`} | ||
> | ||
{message.content} | ||
</div> | ||
</div> | ||
); | ||
} |
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,15 @@ | ||
import { MessageResponseDto } from "../types/MessageResponseDto"; | ||
|
||
interface SystemMessageItemProps { | ||
message: MessageResponseDto; | ||
} | ||
|
||
export default function SystemMessageItem({ message }: SystemMessageItemProps) { | ||
return ( | ||
<div className="flex justify-center my-3"> | ||
<div className="px-4 py-2 rounded-full bg-neutral-300 text-white text-sm text-center"> | ||
{message.content} | ||
</div> | ||
</div> | ||
); | ||
} |
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,5 @@ | ||
// 서버 웹소켓 엔드포인트트 | ||
export const SOCKET_URL = "http://localhost:8080/ws"; | ||
|
||
// 닉네임 최대 길이 | ||
export const MAX_NICKNAME_LENGTH = 30; |
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,3 @@ | ||
export interface MessageRequestDto { | ||
content: string; | ||
} |
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,8 @@ | ||
import { MessageType } from "./MessageType"; | ||
|
||
export interface MessageResponseDto { | ||
type: MessageType; | ||
content: string; | ||
sessionId: string; | ||
nickname: string; | ||
} |
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 @@ | ||
export type MessageType = "SYSTEM" | "CHAT"; |
15 changes: 15 additions & 0 deletions
15
server/src/main/java/com/example/spring_websocket/common/enums/MessageType.java
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,15 @@ | ||
package com.example.spring_websocket.common.enums; | ||
|
||
import org.springframework.web.socket.messaging.SessionConnectEvent; | ||
|
||
/** | ||
* UI 구분을 위한 메시지 타입입니다. | ||
* <ul> | ||
* <li>SYSTEM: 특정 사용자가 아닌 시스템에서 발행한 메시지입니다.</li> | ||
* <li>CHAT: 사용자가 채팅을 목적으로 발행한 메시지입니다.</li> | ||
* </ul> | ||
*/ | ||
public enum MessageType { | ||
SYSTEM, | ||
CHAT | ||
} |
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
8 changes: 4 additions & 4 deletions
8
server/src/main/java/com/example/spring_websocket/dto/response/MessageResponseDto.java
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