-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from bengHak/feature/고병학/firebase-chat
[네트워킹] 파이어베이스 RealtimeDatabase를 활용해서 채팅 기능 구현
- Loading branch information
Showing
35 changed files
with
751 additions
and
144 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
29 changes: 29 additions & 0 deletions
29
NearTalk/NearTalk/Data/Repositories/DefaultChatMessageRepository.swift
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,29 @@ | ||
// | ||
// DefaultChatMessageRepository.swift | ||
// NearTalk | ||
// | ||
// Created by 고병학 on 2022/11/23. | ||
// | ||
|
||
import Foundation | ||
import RxSwift | ||
|
||
final class DefaultChatMessageRepository: ChatMessageRepository { | ||
private let databaseService: RealTimeDatabaseService | ||
|
||
init(databaseService: RealTimeDatabaseService) { | ||
self.databaseService = databaseService | ||
} | ||
|
||
func sendMessage(_ message: ChatMessage) -> Completable { | ||
self.databaseService.sendMessage(message) | ||
} | ||
|
||
func fetchMessage(page: Int, skip: Int, count: Int, roomID: String) -> Single<[ChatMessage]> { | ||
self.databaseService.fetchMessages(page: page, skip: skip, pageCount: count, roomID: roomID) | ||
} | ||
|
||
func observeChatRoomMessages(roomID: String) -> Observable<ChatMessage> { | ||
self.databaseService.observeNewMessage(roomID) | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
NearTalk/NearTalk/Data/Repositories/DefaultMediaRepository.swift
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,25 @@ | ||
// | ||
// DefaultMediaRepository.swift | ||
// NearTalk | ||
// | ||
// Created by 고병학 on 2022/11/23. | ||
// | ||
|
||
import Foundation | ||
import RxSwift | ||
|
||
final class DefaultMediaRepository: MediaRepository { | ||
private let storageService: StorageService | ||
|
||
init(storageService: StorageService) { | ||
self.storageService = storageService | ||
} | ||
|
||
func uploadImage(_ imageData: Data) -> RxSwift.Single<String> { | ||
self.storageService.uploadData(data: imageData, fileName: "\(UUID().uuidString).jpg", dataType: .images) | ||
} | ||
|
||
func uploadVideo(_ videoData: Data) -> RxSwift.Single<String> { | ||
self.storageService.uploadData(data: videoData, fileName: "\(UUID().uuidString).mov", dataType: .videos) | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
NearTalk/NearTalk/Domain/Entities/UserChatRoomTicket.swift
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,16 @@ | ||
// | ||
// UserChatRoomTicket.swift | ||
// NearTalk | ||
// | ||
// Created by 고병학 on 2022/11/23. | ||
// | ||
|
||
import Foundation | ||
|
||
struct UserChatRoomTicket: BaseEntity { | ||
var uuid: String? | ||
var userID: String? | ||
var roomID: String? | ||
var lastReadMessageID: String? | ||
var lastRoomMessageCount: Int? | ||
} |
Oops, something went wrong.