Skip to content

Commit

Permalink
Fixed bug where the retry handler would not initially fire
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrhodes committed Jun 19, 2016
1 parent 788c168 commit 6ca5b29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ActionCableClient.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ActionCableClient"
s.version = "0.1.4"
s.version = "0.1.5"
s.summary = "A Swift client for the Rails ActionCable WebSocket server."
s.description = <<-DESC
ActionCable is a new WebSocket server being released with Rails 5 which makes it easy to add real-time features to your app. This Swift client makes it dead-simple to connect with that server, abstracting away everything except what you need to get going.
Expand Down
7 changes: 4 additions & 3 deletions Pod/Classes/RetryHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public enum RetryStrategy {
case .LogarithmicBackoff(let maxRetries, let maxIntervalTime):
if (retries > maxRetries) { return 0.0 }
let interval = 5 * log(Double(retries))
return NSTimeInterval(clamp(interval, lower: 0.0, upper: Double(maxIntervalTime)))
return NSTimeInterval(clamp(interval, lower: 0.1, upper: Double(maxIntervalTime)))
case .ExponentialBackoff(let maxRetries, let maxIntervalTime):
if (retries > maxRetries) { return 0.0 }
let interval = exp2(Double(retries))
return NSTimeInterval(clamp(Double(interval), lower: 0.0, upper: Double(maxIntervalTime)))
return NSTimeInterval(clamp(Double(interval), lower: 0.1, upper: Double(maxIntervalTime)))
case .Linear(let maxRetries, let intervalTime):
if (retries > maxRetries) { return 0.0 }
return NSTimeInterval(intervalTime)
Expand Down Expand Up @@ -72,13 +72,14 @@ internal class RetryHandler : NSObject {
if (interval > 0.0) {
self.timer = NSTimer.scheduledTimerWithTimeInterval(interval,
target: self,
selector: #selector(RetryHandler.fire(_:)),
selector: #selector(self.fire(_:)),
userInfo: nil,
repeats: false)
}
}

internal func fire(timer : NSTimer) {

if let callback = self.callback {
callback()
}
Expand Down

0 comments on commit 6ca5b29

Please sign in to comment.