mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Don't time out
This commit is contained in:
parent
33186e34fa
commit
0ac2aaf8bb
3 changed files with 1 additions and 21 deletions
|
@ -94,10 +94,6 @@ final class DeviceLinkingModal : UIViewController, LokiDeviceLinkingSessionDeleg
|
|||
|
||||
// MARK: Device Linking
|
||||
func requestUserAuthorization(for deviceLink: LokiDeviceLink) {
|
||||
|
||||
}
|
||||
|
||||
func handleDeviceLinkingSessionTimeout() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,30 +3,21 @@ import PromiseKit
|
|||
@objc (LKDeviceLinkingSession)
|
||||
public final class LokiDeviceLinkingSession : NSObject {
|
||||
private let delegate: LokiDeviceLinkingSessionDelegate
|
||||
private var timer: Timer?
|
||||
@objc public var isListeningForLinkingRequests = false
|
||||
|
||||
// MARK: Lifecycle
|
||||
@objc public init(delegate: LokiDeviceLinkingSessionDelegate) {
|
||||
self.delegate = delegate
|
||||
}
|
||||
|
||||
// MARK: Settings
|
||||
private let listeningTimeout: TimeInterval = 60
|
||||
|
||||
// MARK: Public API
|
||||
@objc public func startListeningForLinkingRequests() {
|
||||
isListeningForLinkingRequests = true
|
||||
timer = Timer.scheduledTimer(withTimeInterval: listeningTimeout, repeats: false) { [weak self] timer in
|
||||
guard let self = self else { return }
|
||||
self.stopListeningForLinkingRequests()
|
||||
self.delegate.handleDeviceLinkingSessionTimeout()
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func processLinkingRequest(from slaveHexEncodedPublicKey: String, with slaveSignature: Data) {
|
||||
guard isListeningForLinkingRequests else { return }
|
||||
stopListeningForLinkingRequests()
|
||||
isListeningForLinkingRequests = false
|
||||
let master = LokiDeviceLink.Device(hexEncodedPublicKey: OWSIdentityManager.shared().identityKeyPair()!.hexEncodedPublicKey)
|
||||
let slave = LokiDeviceLink.Device(hexEncodedPublicKey: slaveHexEncodedPublicKey, signature: slaveSignature)
|
||||
let deviceLink = LokiDeviceLink(between: master, and: slave)
|
||||
|
@ -38,12 +29,6 @@ public final class LokiDeviceLinkingSession : NSObject {
|
|||
// TODO: Send a device link authorized message
|
||||
}
|
||||
|
||||
@objc public func stopListeningForLinkingRequests() {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
isListeningForLinkingRequests = false
|
||||
}
|
||||
|
||||
// MARK: Private API
|
||||
private func isValid(_ deviceLink: LokiDeviceLink) -> Bool {
|
||||
return true // TODO: Implement
|
||||
|
|
|
@ -3,5 +3,4 @@
|
|||
public protocol LokiDeviceLinkingSessionDelegate {
|
||||
|
||||
@objc func requestUserAuthorization(for deviceLink: LokiDeviceLink)
|
||||
@objc func handleDeviceLinkingSessionTimeout()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue