18 lines
475 B
Swift
18 lines
475 B
Swift
|
import Foundation
|
||
|
|
||
|
struct ServerChallenge {
|
||
|
|
||
|
private static let challengeExpiryTime: TimeInterval = 25.0
|
||
|
|
||
|
let creationDate: Date
|
||
|
|
||
|
let message: Message
|
||
|
|
||
|
var isExpired: Bool {
|
||
|
creationDate.addingTimeInterval(ServerChallenge.challengeExpiryTime) < Date.now
|
||
|
}
|
||
|
}
|
||
|
|
||
|
typealias ServerResponse = (result: Message, challenge: ServerChallenge?)
|
||
|
typealias OptionalServerResponse = (success: Bool, result: Message?, challenge: ServerChallenge?)
|