Permalink
Browse files

Merge pull request #9 from mloughran/add_on_connect

Not possible to reserve on connected reliably
  • Loading branch information...
2 parents 351704a + 024014c commit ecd85bf2747af1c58be7ce83ca517b40623598bb @dj2 dj2 committed Sep 10, 2011
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/em-jack/connection.rb
View
@@ -246,9 +246,12 @@ def connected
@reconnect_proc = nil
@retries = 0
succeed
+ @connected = true
+ @connected_callback.call if @connected_callback
end
def disconnected
+ @connected = false
d = @deferrables.dup
## if reconnecting, need to fail ourself to remove any callbacks
@@ -316,6 +319,14 @@ def on_disconnect(&blk)
@disconnected_callback = blk
end
+ def on_connect(&blk)
+ @connected_callback = blk
+ end
+
+ def connected?
+ @connected
+ end
+
def received(data)
@data << data

0 comments on commit ecd85bf

Please sign in to comment.