Class: ActionCable::Connection::WebSocket

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (Boolean)


19
20
21
# File 'lib/action_cable/connection/web_socket.rb', line 19

def alive?
  websocket && websocket.alive?
end

#closeObject



27
28
29
# File 'lib/action_cable/connection/web_socket.rb', line 27

def close
  websocket.close
end

#possible?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/action_cable/connection/web_socket.rb', line 15

def possible?
  websocket
end

#protocolObject



31
32
33
# File 'lib/action_cable/connection/web_socket.rb', line 31

def protocol
  websocket.protocol
end

#rack_responseObject



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