Class: Async::WebSocket::Connection

Inherits:
Protocol::WebSocket::Connection
  • Object
show all
Includes:
Protocol::WebSocket::Headers
Defined in:
lib/async/websocket/connection.rb

Overview

This is a basic synchronous websocket client:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(framer, protocol = nil, **options) ⇒ Connection

Returns a new instance of Connection.



34
35
36
37
38
# File 'lib/async/websocket/connection.rb', line 34

def initialize(framer, protocol = nil, **options)
  super(framer, **options)
  
  @protocol = protocol
end

Instance Attribute Details

#protocolObject (readonly)

Returns the value of attribute protocol.



44
45
46
# File 'lib/async/websocket/connection.rb', line 44

def protocol
  @protocol
end

Class Method Details

.call(framer, protocol = [], extensions = nil, **options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/async/websocket/connection.rb', line 20

def self.call(framer, protocol = [], extensions = nil, **options)
  instance = self.new(framer, Array(protocol).first, **options)
  
  extensions&.apply(instance)
  
  return instance unless block_given?
  
  begin
    yield instance
  ensure
    instance.close
  end
end

Instance Method Details

#inspectObject



46
47
48
# File 'lib/async/websocket/connection.rb', line 46

def inspect
  "#<#{self.class} state=#{@state}>"
end

#reusable?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/async/websocket/connection.rb', line 40

def reusable?
  false
end