Class: Daytona::Common::WebSocketDialer::VerifyingClient
- Inherits:
-
WebSocket::Client::Simple::Client
- Object
- WebSocket::Client::Simple::Client
- Daytona::Common::WebSocketDialer::VerifyingClient
- Defined in:
- lib/daytona/common/websocket_dialer.rb
Overview
A websocket-client-simple client that verifies the peer before writing.
#connect is reimplemented rather than extended because the upstream
method builds the socket, performs the TLS handshake and writes the
request in one pass, and returns early when @socket is already set.
Everything after TLS setup mirrors upstream so that framing, the reader
thread and event semantics stay identical. That couples to the instance
variables the inherited #send, #close, #open? and #closed? read,
so the gemspec pins the gem to ~> 0.9.0 - a 0.x minor bump could rename
them. websocket_dialer_spec.rb drives a full send/close round trip
against a real listener, which fails if that contract breaks.
Instance Method Summary collapse
Instance Method Details
#connect(url, options = {}) ⇒ void
This method returns an undefined value.
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/daytona/common/websocket_dialer.rb', line 63 def connect(url, = {}) return if @socket @url = url uri = URI.parse(url) @socket = TCPSocket.new(uri.host, uri.port || (uri.scheme == 'wss' ? 443 : 80)) @socket = verified_ssl_socket(@socket, uri, ) if %w[https wss].include?(uri.scheme) start_websocket(url, ) end |