Class: OMQ::Transport::WebSocket::Dialer
- Inherits:
-
Object
- Object
- OMQ::Transport::WebSocket::Dialer
- Defined in:
- lib/omq/transport/websocket/transport.rb
Overview
Outgoing connection factory. Stateful so reconnect can call
#connect again without redoing endpoint parsing.
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
-
#connect ⇒ void
Establishes the WebSocket upgrade and hands the resulting Async::WebSocket::Connection to the engine.
-
#initialize(endpoint, engine) ⇒ Dialer
constructor
A new instance of Dialer.
Constructor Details
#initialize(endpoint, engine) ⇒ Dialer
Returns a new instance of Dialer.
119 120 121 122 |
# File 'lib/omq/transport/websocket/transport.rb', line 119 def initialize(endpoint, engine) @endpoint = endpoint @engine = engine end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
116 117 118 |
# File 'lib/omq/transport/websocket/transport.rb', line 116 def endpoint @endpoint end |
Instance Method Details
#connect ⇒ void
This method returns an undefined value.
Establishes the WebSocket upgrade and hands the resulting
Async::WebSocket::Connection to the engine. The engine builds
the OMQ::Transport::WebSocket::Connection on top via the
transport's connection_class hook and runs the ZWS
handshake.
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/omq/transport/websocket/transport.rb', line 133 def connect tls = @engine..tls_context subprotocols = @engine..ws_subprotocols http_endpoint = WebSocket.parse_http_endpoint(@endpoint, tls) ws_conn = ::Async::WebSocket::Client.connect( http_endpoint, protocols: subprotocols, ) @engine.handle_connected(ws_conn, endpoint: @endpoint) end |