Class: ActionCable::Connection::WebSocket
- Inherits:
-
Object
- Object
- ActionCable::Connection::WebSocket
- Defined in:
- lib/action_cable/connection/web_socket.rb
Overview
Action Cable Connection WebSocket
Wrap the real socket to minimize the externally-presented API
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #close ⇒ Object
-
#initialize(env, event_target, event_loop, protocols: ActionCable::INTERNAL[:protocols]) ⇒ WebSocket
constructor
:nodoc:.
- #possible? ⇒ Boolean
- #protocol ⇒ Object
- #rack_response ⇒ Object
- #transmit(data) ⇒ Object
Constructor Details
#initialize(env, event_target, event_loop, protocols: ActionCable::INTERNAL[:protocols]) ⇒ WebSocket
:nodoc:
11 12 13 |
# File 'lib/action_cable/connection/web_socket.rb', line 11 def initialize(env, event_target, event_loop, protocols: ActionCable::INTERNAL[:protocols]) @websocket = ::WebSocket::Driver.websocket?(env) ? ClientSocket.new(env, event_target, event_loop, protocols) : nil end |
Instance Method Details
#alive? ⇒ Boolean
19 20 21 |
# File 'lib/action_cable/connection/web_socket.rb', line 19 def alive? websocket && websocket.alive? end |
#close ⇒ Object
27 28 29 |
# File 'lib/action_cable/connection/web_socket.rb', line 27 def close websocket.close end |
#possible? ⇒ Boolean
15 16 17 |
# File 'lib/action_cable/connection/web_socket.rb', line 15 def possible? websocket end |
#protocol ⇒ Object
31 32 33 |
# File 'lib/action_cable/connection/web_socket.rb', line 31 def protocol websocket.protocol end |
#rack_response ⇒ Object
35 36 37 |
# File 'lib/action_cable/connection/web_socket.rb', line 35 def rack_response websocket.rack_response end |
#transmit(data) ⇒ Object
23 24 25 |
# File 'lib/action_cable/connection/web_socket.rb', line 23 def transmit(data) websocket.transmit data end |