Class: Async::WebSocket::Client

Inherits:
Protocol::HTTP::Middleware
  • Object
show all
Includes:
Protocol::WebSocket::Headers
Defined in:
lib/deepstream/async_patch.rb

Class Method Summary collapse

Class Method Details

.connect(endpoint, *args, **options, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/deepstream/async_patch.rb', line 6

def self.connect(endpoint, *args, **options, &block)
  self.open(endpoint, *args) do |client|
    connection = client.connect(endpoint.path, **options)

    return connection unless block_given?

    begin
      yield connection
    ensure
      connection.close
    end
  rescue
    puts "cant connect to #{endpoint}"
  end
end