Class: NATS::IO::WebSocket
- Inherits:
-
Object
- Object
- NATS::IO::WebSocket
- Defined in:
- lib/stack-service-base/nats_patch_1.rb
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(options = {}) ⇒ WebSocket
constructor
A new instance of WebSocket.
Constructor Details
#initialize(options = {}) ⇒ WebSocket
Returns a new instance of WebSocket.
8 9 10 11 |
# File 'lib/stack-service-base/nats_patch_1.rb', line 8 def initialize( = {}) super @options = end |
Instance Method Details
#connect ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/stack-service-base/nats_patch_1.rb', line 13 def connect super setup_tls! if @uri.scheme == "wss" # WebSocket connection must be made over TLS from the beginning @handshake = ::WebSocket::Handshake::Client.new url: @uri.to_s, **@options @frame = ::WebSocket::Frame::Incoming::Client.new @handshaked = false @socket.write @handshake.to_s until @handshaked @handshake << method(:read).super_method.call(MAX_SOCKET_READ_BYTES) if @handshake.finished? @handshaked = true end end end |