SignalingParticipant.swift 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. import Foundation
  6. import SwiftyAttributes
  7. @objcMembers public class SignalingParticipant: NSObject {
  8. public var userId: String?
  9. public var displayName: String?
  10. public var signalingSessionId: String?
  11. public var isFederated: Bool = false
  12. // actorId/actorType are only available starting >= NC30
  13. public var actorId: String?
  14. public var actorType: String?
  15. public var actor: TalkActor? {
  16. if let actorId, let actorType {
  17. return TalkActor(actorId: actorId, actorType: actorType, actorDisplayName: self.displayName)
  18. } else if let userId, !userId.isEmpty {
  19. return TalkActor(actorId: userId, actorType: "users", actorDisplayName: self.displayName)
  20. }
  21. // TODO: Support guest actors as well
  22. return nil
  23. }
  24. init(withJoinDictionary dict: [AnyHashable: Any]) {
  25. self.userId = dict["userid"] as? String
  26. if let userDict = dict["user"] as? [AnyHashable: Any] {
  27. self.displayName = userDict["displayname"] as? String
  28. }
  29. self.signalingSessionId = dict["sessionid"] as? String
  30. self.isFederated = dict["federated"] as? Bool ?? false
  31. }
  32. public func update(withUpdateDictionary dict: [AnyHashable: Any]) {
  33. self.actorId = dict["actorId"] as? String
  34. self.actorType = dict["actorType"] as? String
  35. }
  36. }