Class: Slack::RealTime::Concurrency::Async::Socket

Inherits:
Socket
  • Object
show all
Defined in:
lib/slack/real_time/concurrency/async.rb

Instance Attribute Summary collapse

Attributes inherited from Socket

#driver, #options, #url

Instance Method Summary collapse

Methods inherited from Socket

#connected?, #disconnect!, #initialize, #send_data, #start_sync

Constructor Details

This class inherits a constructor from Slack::RealTime::Socket

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



13
14
15
# File 'lib/slack/real_time/concurrency/async.rb', line 13

def client
  @client
end

Instance Method Details

#closeObject



28
29
30
31
32
# File 'lib/slack/real_time/concurrency/async.rb', line 28

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

#connect!Object



23
24
25
26
# File 'lib/slack/real_time/concurrency/async.rb', line 23

def connect!
  super
  run_loop
end

#run_loopObject



34
35
36
37
38
39
# File 'lib/slack/real_time/concurrency/async.rb', line 34

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

#start_async(client) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/slack/real_time/concurrency/async.rb', line 15

def start_async(client)
  Thread.new do
    ::Async::Reactor.run do
      client.run_loop
    end
  end
end