RoomService.swift 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // RoomService.swift
  3. // TUIRoomKit
  4. //
  5. // Created by CY zhao on 2024/7/2.
  6. //
  7. import Foundation
  8. import RTCRoomEngine
  9. import ImSDK_Plus
  10. import Combine
  11. class RoomService {
  12. private let engineManager = EngineManager.shared
  13. func enterRoom(roomId: String,
  14. options: TUIEnterRoomOptions? = nil,
  15. enableAudio: Bool,
  16. enableVideo: Bool,
  17. isSoundOnSpeaker: Bool) -> AnyPublisher<Void, RoomError> {
  18. return Future<Void, RoomError> { [weak self] promise in
  19. guard let self = self else { return }
  20. //TODO: use RTCRoomEngine directly
  21. self.engineManager.enterRoom(roomId: roomId,
  22. options: options,
  23. enableAudio: enableAudio,
  24. enableVideo: enableVideo,
  25. isSoundOnSpeaker: isSoundOnSpeaker) { roomInfo in
  26. promise(.success(()))
  27. } onError: { error, message in
  28. let error = RoomError(error: error, message: message)
  29. promise(.failure(error))
  30. }
  31. }
  32. .eraseToAnyPublisher()
  33. }
  34. }