Skip to content

Commit

Permalink
feat: add `setClientRole(role: ClientRole, options?: ClientRoleOption…
Browse files Browse the repository at this point in the history
…s): Promise<void>`
  • Loading branch information
LichKing-2234 committed Dec 15, 2020
1 parent 4ee51a9 commit 3a55997
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions BeanCovertor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,13 @@ func mapToEncryptionConfig(_ map: Dictionary<String, Any>) -> AgoraEncryptionCon
}
return encryptionConfig
}

func mapToClientRoleOptions(_ map: Dictionary<String, Any>) -> AgoraClientRoleOptions {
let clientRoleOptions = AgoraClientRoleOptions()
if let audienceLatencyLevel = map["audienceLatencyLevel"] as? Int {
if let audienceLatencyLevel = AgoraAudienceLatencyLevelType(rawValue: audienceLatencyLevel) {
clientRoleOptions.audienceLatencyLevel = audienceLatencyLevel
}
}
return clientRoleOptions
}
7 changes: 6 additions & 1 deletion RtcChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,12 @@ class RtcChannelManager: NSObject, RtcChannelInterface {
}

@objc func setClientRole(_ params: NSDictionary, _ callback: Callback) {
callback.code(self[params["channelId"] as! String]?.setClientRole(AgoraClientRole(rawValue: params["role"] as! Int)!))
let role = AgoraClientRole(rawValue: params["role"] as! Int)!
if let options = params["options"] as? Dictionary<String, Any> {
callback.code(self[params["channelId"] as! String]?.setClientRole(role, options: mapToClientRoleOptions(options)))
return
}
callback.code(self[params["channelId"] as! String]?.setClientRole(role))
}

@objc func joinChannel(_ params: NSDictionary, _ callback: Callback) {
Expand Down
7 changes: 6 additions & 1 deletion RtcEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,12 @@ class RtcEngineManager: NSObject, RtcEngineInterface {
}

@objc func setClientRole(_ params: NSDictionary, _ callback: Callback) {
callback.code(engine?.setClientRole(AgoraClientRole(rawValue: params["role"] as! Int)!))
let role = AgoraClientRole(rawValue: params["role"] as! Int)!
if let options = params["options"] as? Dictionary<String, Any> {
callback.code(engine?.setClientRole(role, options: mapToClientRoleOptions(options)))
return
}
callback.code(engine?.setClientRole(role))
}

@objc func joinChannel(_ params: NSDictionary, _ callback: Callback) {
Expand Down

0 comments on commit 3a55997

Please sign in to comment.