Skip to content

Commit

Permalink
Close socket, terminate reactor, closes #222.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Sep 7, 2018
1 parent b1b681a commit 115942e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/slack/real_time/concurrency/async.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Concurrency
module Async
class Client < ::Async::WebSocket::Client
extend ::Forwardable
def_delegators :@driver, :on, :text, :binary
def_delegators :@driver, :on, :text, :binary, :emit
end

class Socket < Slack::RealTime::Socket
Expand All @@ -26,11 +26,13 @@ def connect!
end

def close
@driver.close
@closing = true
@driver.close if @driver
super
end

def run_loop
@closing = false
while @driver && @driver.next_event
# $stderr.puts event.inspect
end
Expand All @@ -50,8 +52,13 @@ def build_endpoint
endpoint
end

def connect_socket
build_endpoint.connect
end

def connect
@driver = Client.new(build_endpoint.connect, url)
@socket = connect_socket
@driver = Client.new(@socket, url)
end
end
end
Expand Down

0 comments on commit 115942e

Please sign in to comment.