Class: ActionCable::Connection::WebSocket

Inherits:
Object
  • Object
show all
Defined in:
actioncable/lib/action_cable/connection/web_socket.rb

Overview

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

Returns a new instance of WebSocket.



9
10
11
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 9

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)


17
18
19
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 17

def alive?
  websocket && websocket.alive?
end

#closeObject



25
26
27
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 25

def close
  websocket.close
end

#possible?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 13

def possible?
  websocket
end

#protocolObject



29
30
31
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 29

def protocol
  websocket.protocol
end

#rack_responseObject



33
34
35
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 33

def rack_response
  websocket.rack_response
end

#transmit(data) ⇒ Object



21
22
23
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 21

def transmit(data)
  websocket.transmit data
end