mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
827 B
Swift
32 lines
827 B
Swift
3 years ago
|
// Copyright © 2021 Rangeproof Pty Ltd. All rights reserved.
|
||
|
|
||
![]()
1 year ago
|
// stringlint:disable
|
||
|
|
||
3 years ago
|
import Foundation
|
||
3 years ago
|
import SessionUtilitiesKit
|
||
3 years ago
|
|
||
|
struct TurnServerInfo {
|
||
|
|
||
|
let password: String
|
||
|
let username: String
|
||
|
let urls: [String]
|
||
|
|
||
10 months ago
|
init?(attributes: [String: Any], random: Int? = nil) {
|
||
3 years ago
|
guard
|
||
|
let passwordAttribute = attributes["password"] as? String,
|
||
|
let usernameAttribute = attributes["username"] as? String,
|
||
|
let urlsAttribute = attributes["urls"] as? [String]
|
||
|
else {
|
||
3 years ago
|
return nil
|
||
|
}
|
||
3 years ago
|
|
||
|
password = passwordAttribute
|
||
|
username = usernameAttribute
|
||
|
urls = {
|
||
|
guard let random: Int = random else { return urlsAttribute }
|
||
3 years ago
|
|
||
3 years ago
|
return Array(urlsAttribute.shuffled()[0..<random])
|
||
|
}()
|
||
3 years ago
|
}
|
||
|
}
|