Class: Async::WebSocket::Connection
- Inherits:
-
Protocol::WebSocket::Connection
- Object
- Protocol::WebSocket::Connection
- Async::WebSocket::Connection
- Includes:
- Protocol::WebSocket::Headers
- Defined in:
- lib/async/websocket/connection.rb
Overview
This is a basic synchronous websocket client:
Instance Attribute Summary collapse
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #close ⇒ Object
-
#initialize(framer, protocol = nil, response: nil, **options) ⇒ Connection
constructor
A new instance of Connection.
- #reusable? ⇒ Boolean
Constructor Details
#initialize(framer, protocol = nil, response: nil, **options) ⇒ Connection
33 34 35 36 37 38 |
# File 'lib/async/websocket/connection.rb', line 33 def initialize(framer, protocol = nil, response: nil, **) super(framer, **) @protocol = protocol @response = response end |
Instance Attribute Details
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
53 54 55 |
# File 'lib/async/websocket/connection.rb', line 53 def protocol @protocol end |
Class Method Details
.call(framer, protocol = [], extensions = nil, **options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/async/websocket/connection.rb', line 19 def self.call(framer, protocol = [], extensions = nil, **) instance = self.new(framer, Array(protocol).first, **) extensions&.apply(instance) return instance unless block_given? begin yield instance ensure instance.close end end |
Instance Method Details
#call ⇒ Object
55 56 57 |
# File 'lib/async/websocket/connection.rb', line 55 def call self.close end |
#close ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/async/websocket/connection.rb', line 44 def close super if @response @response.finish @response = nil end end |
#reusable? ⇒ Boolean
40 41 42 |
# File 'lib/async/websocket/connection.rb', line 40 def reusable? false end |