-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: qfeed-99 채팅 한글 두번 전송 되는 오류 해결, 커서 위치 변경 * fix: qfeed-99 firebase api 키 추가 * feat: qfeed-99 채팅api 연동 * fix: qfeed-99 merge * fix: qfeed-99 패치 방법 변경 * feat: qfeed-99 채팅 리스트 연동 후 구현 * feat: qfeed-99 채팅 내역 조회 api 연동 완료 * feat: qfeed-99 채팅 내역 띄우기 완료 * feat: qfeed-99 채팅웹소켓 통신 메세지 전송 기능 완료, isMine 적용 * fix: qfeed-99 구독 경로 수정 * fix: qfeed-99 merge * fix: qfeed-99 채팅 조회, 전송 완료
- Loading branch information
Showing
17 changed files
with
360 additions
and
154 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
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
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,18 @@ | ||
import { apiClient } from '@/api/fetch'; | ||
import { ChatData } from '@/pages/ChatList/type/chatListType'; | ||
|
||
export const chatAPI = { | ||
// 채팅방 목록 가져오기 | ||
getChatList: () => apiClient.get<ChatData[]>('/chats'), | ||
}; | ||
|
||
export const fetchChatList = async (): Promise<ChatData[]> => { | ||
try { | ||
const response = await chatAPI.getChatList(); | ||
console.log('응답 데이터: ', response.data); // 응답 확인 | ||
return response.data || []; | ||
} catch (error) { | ||
console.error('API 요청 중 오류 발생: ', error); // 에러 확인 | ||
return []; | ||
} | ||
}; |
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
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 @@ | ||
export interface ChatData { | ||
chatRoomId: string; // 채팅방 ID | ||
otherUserProfile?: string; // 프로필 이미지 URL | ||
otherUserNickname: string; // 사용자 이름 | ||
lastMessageContent: string; // 마지막 메시지 | ||
lastMessageCreatedAt: string; // 메시지 시간 | ||
unreadMessageCount?: number; // 읽지 않은 메시지 수 | ||
} |
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,19 @@ | ||
import { apiClient } from '@/api/fetch'; | ||
import { MessageType } from '@/pages/ChatRoom/type/messageType'; | ||
|
||
export const messageAPI = { | ||
// 특정 채팅방 메시지 가져오기 | ||
getMessages: (chatRoomId: string) => | ||
apiClient.get<MessageType[]>(`/chats/${chatRoomId}/messages`), | ||
}; | ||
|
||
export const fetchMessages = async (chatRoomId: string): Promise<MessageType[]> => { | ||
try { | ||
const response = await messageAPI.getMessages(chatRoomId); | ||
console.log('응답 데이터: ', response.data); // 응답 확인 | ||
return response.data || []; // 데이터 반환 | ||
} catch (error) { | ||
console.error('메시지 조회 중 오류 발생: ', error); // 에러 확인 | ||
return []; | ||
} | ||
}; |
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,37 @@ | ||
import { Client } from '@stomp/stompjs'; | ||
|
||
// WebSocket URL 설정 | ||
const SOCKET_URL = 'wss://q-feed.n-e.kr/ws'; | ||
|
||
// STOMP 클라이언트 생성 | ||
export const stompClient = new Client({ | ||
brokerURL: SOCKET_URL, // WebSocket URL | ||
reconnectDelay: 5000, // 재연결 대기 시간 (ms) | ||
debug: (str) => { | ||
console.log('STOMP Debug:', str); | ||
}, | ||
connectHeaders: { | ||
Authorization: 'Token', // 토큰 인증 (필요한 경우) | ||
}, | ||
}); | ||
|
||
// STOMP 연결 함수 | ||
export const connectStomp = () => { | ||
stompClient.onConnect = (frame) => { | ||
console.log('STOMP 연결 성공:', frame); | ||
}; | ||
|
||
stompClient.onStompError = (frame) => { | ||
console.error('STOMP 에러:', frame.headers['message']); | ||
}; | ||
|
||
stompClient.activate(); // STOMP 활성화 | ||
}; | ||
|
||
// STOMP 연결 해제 함수 | ||
export const disconnectStomp = () => { | ||
if (stompClient.active) { | ||
stompClient.deactivate(); | ||
console.log('STOMP 연결 해제'); | ||
} | ||
}; |
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
Oops, something went wrong.