Skip to content

Commit 055b5a7

Browse files
ioquatixdblock
authored andcommitted
Better handling of disconnect!/close.
1 parent a9dabc5 commit 055b5a7

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-01-19 17:37:31 -0500 using RuboCop version 0.61.1.
3+
# on 2019-04-06 10:51:06 -0400 using RuboCop version 0.61.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### 0.14.2 (Next)
22

33
* [#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).
4+
* [#262](https://github.com/slack-ruby/slack-ruby-client/pull/262): Better handling of `disconnect!`/`close` - [@ioquatix](https://github.com/ioquatix).
45
* Your contribution here.
56

67
### 0.14.1 (2019/2/26)

lib/slack/real_time/concurrency/async.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ def restart_async(client, new_url)
4343
end
4444
end
4545

46-
def disconnect!
47-
super
48-
@reactor.cancel
49-
end
50-
5146
def current_time
5247
::Async::Clock.now
5348
end
@@ -57,14 +52,20 @@ def connect!
5752
run_loop
5853
end
5954

55+
# Send a close event and stop the reactor.
56+
def disconnect!
57+
@reactor.cancel
58+
super
59+
close
60+
end
61+
62+
# Close the socket.
6063
def close
61-
@closing = true
62-
@driver.close if @driver
64+
@socket.close if @socket
6365
super
6466
end
6567

6668
def run_loop
67-
@closing = false
6869
while @driver && @driver.next_event
6970
# $stderr.puts event.inspect
7071
end

0 commit comments

Comments
 (0)