Override keep-alive with pushed interval

This commit is contained in:
Davide De Rosa 2018-09-08 20:29:29 +02:00
parent 4bf02198d1
commit 3a02557b5e

View File

@ -85,6 +85,18 @@ public class SessionProxy {
private let configuration: Configuration
private var keepAliveInterval: TimeInterval? {
let interval: TimeInterval?
if let negInterval = pushReply?.ping, negInterval > 0 {
interval = TimeInterval(negInterval)
} else if let cfgInterval = configuration.keepAliveInterval, cfgInterval > 0.0 {
interval = cfgInterval
} else {
return nil
}
return interval
}
/// An optional `SessionProxyDelegate` for receiving session events.
public weak var delegate: SessionProxyDelegate?
@ -1040,6 +1052,9 @@ public class SessionProxy {
if let negFraming = pushedFraming {
log.debug("Negotiated compression framing: \(negFraming.rawValue)")
}
if let negPing = pushReply.ping {
log.debug("Negotiated keep-alive: \(negPing) seconds")
}
let pushedCipher = pushReply.cipher
if let negCipher = pushedCipher {
log.debug("Negotiated cipher: \(negCipher.rawValue)")