Class: Async::WebSocket::Client
- Inherits:
-
Protocol::HTTP::Middleware
- Object
- Protocol::HTTP::Middleware
- Async::WebSocket::Client
- Includes:
- Protocol::WebSocket::Headers
- Defined in:
- lib/deepstream/async_patch.rb
Class Method Summary collapse
Class Method Details
.connect(endpoint, *args, **options, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/deepstream/async_patch.rb', line 18 def self.connect(endpoint, *args, **, &block) self.open(endpoint, *args) do |client| connection = client.connect(endpoint.path, **) return connection unless block_given? begin yield connection ensure connection.close end rescue puts "cant connect to #{endpoint}" end end |
.open(endpoint, *args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/deepstream/async_patch.rb', line 6 def self.open(endpoint, *args, &block) client = self.new(HTTP::Client.new(endpoint, *args), mask: true) return client unless block_given? begin yield client ensure client.close end end |