feat(chat-room) 채팅방 API
- 생성, 입장, 이전 메시지 로딩, 메시지 전송 API 추가
This commit is contained in:
		@@ -12,4 +12,27 @@ import Moya
 | 
			
		||||
 | 
			
		||||
class ChatRoomRepository {
 | 
			
		||||
    private let talkApi = MoyaProvider<TalkApi>()
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 채팅방 입장: 서버 캐릭터 정보 + 최신 메시지 수신
 | 
			
		||||
     */
 | 
			
		||||
    func enterChatRoom(roomId: Int, characterImageId: Int?) -> AnyPublisher<Response, MoyaError> {
 | 
			
		||||
        return talkApi.requestPublisher(.enterChatRoom(roomId: roomId, characterImageId: characterImageId))
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 점진적 메시지 로딩: 커서 기반으로 이전 메시지를 조회
 | 
			
		||||
     */
 | 
			
		||||
    func loadMoreMessages(roomId: Int, cursor: Int?) -> AnyPublisher<Response, MoyaError> {
 | 
			
		||||
        return talkApi.requestPublisher(.getChatRoomMessages(roomId: roomId, cursor: cursor, limit: 20))
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * 메시지 전송 API 호출
 | 
			
		||||
     * - 성공 시: 서버에서 내려온 메시지를 로컬에 반영한다.
 | 
			
		||||
     * - 반환: 서버에서 내려온 메시지(ServerChatMessage) (대개 AI 응답일 것으로 가정)
 | 
			
		||||
     */
 | 
			
		||||
    func sendMessage(roomId: Int, message: String) -> AnyPublisher<Response, MoyaError> {
 | 
			
		||||
        return talkApi.requestPublisher(.sendMessage(roomId: roomId, request: SendChatMessageRequest(message: message)))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,5 +6,5 @@
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
struct CreateChatRoomRequest: Encodable {
 | 
			
		||||
    let characterId: Int64
 | 
			
		||||
    let characterId: Int
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user