Class: ActionCable::Connection::WebSocket

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

Overview

Оберните реальный сокет, чтобы минимизировать внешний API

Instance Method Summary collapse

Constructor Details

#initialize(env, event_target, event_loop, client_socket_class, protocols: ActionCable::INTERNAL[:protocols]) ⇒ WebSocket

Returns a new instance of WebSocket.


7
8
9
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 7

def initialize(env, event_target, event_loop, client_socket_class, protocols: ActionCable::INTERNAL[:protocols])
  @websocket = ::WebSocket::Driver.websocket?(env) ? client_socket_class.new(env, event_target, event_loop, protocols) : nil
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)

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

def alive?
  websocket && websocket.alive?
end

#closeObject


23
24
25
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 23

def close
  websocket.close
end

#possible?Boolean

Returns:

  • (Boolean)

11
12
13
# File 'actioncable/lib/action_cable/connection/web_socket.rb', line 11

def possible?
  websocket
end

#protocolObject


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

def protocol
  websocket.protocol
end

#rack_responseObject


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

def rack_response
  websocket.rack_response
end

#transmit(data) ⇒ Object


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

def transmit(data)
  websocket.transmit data
end