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
Returns a new instance of Connection.
48 49 50 51 52 53 |
# File 'lib/async/websocket/connection.rb', line 48 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.
68 69 70 |
# File 'lib/async/websocket/connection.rb', line 68 def protocol @protocol end |
Class Method Details
.call(framer, protocol = [], extensions = nil, **options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/async/websocket/connection.rb', line 34 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
70 71 72 |
# File 'lib/async/websocket/connection.rb', line 70 def call self.close end |
#close ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/async/websocket/connection.rb', line 59 def close super if @response @response.finish @response = nil end end |
#reusable? ⇒ Boolean
55 56 57 |
# File 'lib/async/websocket/connection.rb', line 55 def reusable? false end |