Class: Async::WebSocket::Client
- Inherits:
-
Connection
- Object
- Connection
- Async::WebSocket::Client
- Defined in:
- lib/async/websocket/client.rb
Overview
This is a basic synchronous websocket client:
Constant Summary
Constants inherited from Connection
Async::WebSocket::Connection::BLOCK_SIZE, Async::WebSocket::Connection::EVENTS
Instance Attribute Summary
Attributes inherited from Connection
Instance Method Summary collapse
- #build_client(headers: nil, **options) ⇒ Object
-
#initialize(socket, url = "ws://.", **options) ⇒ Client
constructor
A new instance of Client.
Methods inherited from Connection
#close, #next_event, #next_message, #send_message, #send_text, #write
Constructor Details
#initialize(socket, url = "ws://.", **options) ⇒ Client
Returns a new instance of Client.
27 28 29 30 31 |
# File 'lib/async/websocket/client.rb', line 27 def initialize(socket, url = "ws://.", **) @url = url super socket, build_client(**) end |
Instance Method Details
#build_client(headers: nil, **options) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/async/websocket/client.rb', line 33 def build_client(headers: nil, **) ::WebSocket::Driver.client(self, ).tap do |client| headers&.each do |key, value| client.set_header(key, value) end end end |