Skip to content

Commit

Permalink
Better handling of disconnect!/close.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored and dblock committed Apr 6, 2019
1 parent a9dabc5 commit 8863848
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-01-19 17:37:31 -0500 using RuboCop version 0.61.1.
# on 2019-04-06 10:51:06 -0400 using RuboCop version 0.61.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
### 0.14.2 (Next)

* [#256](https://github.com/slack-ruby/slack-ruby-client/pull/256): Added support for specifying signing secrets on a per-request basis via optional parameters to the `Slack::Events::Request` constructor - [@gabrielmdeal](https://github.com/gabrielmdeal).
* [#262](https://github.com/slack-ruby/slack-ruby-client/pull/262): Better handling of `disconnect!`/`close` - [@ioquatix](https://github.com/ioquatix).
* Your contribution here.

### 0.14.1 (2019/2/26)
Expand Down
17 changes: 9 additions & 8 deletions lib/slack/real_time/concurrency/async.rb
Expand Up @@ -43,11 +43,6 @@ def restart_async(client, new_url)
end
end

def disconnect!
super
@reactor.cancel
end

def current_time
::Async::Clock.now
end
Expand All @@ -57,14 +52,20 @@ def connect!
run_loop
end

# Send a close event and stop the reactor.
def disconnect!
super
@reactor.cancel
close
end

# Close the socket.
def close
@closing = true
@driver.close if @driver
@socket.close if @socket
super
end

def run_loop
@closing = false
while @driver && @driver.next_event
# $stderr.puts event.inspect
end
Expand Down

0 comments on commit 8863848

Please sign in to comment.