aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/connection/web_socket.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-01-28 15:25:31 +1030
committerMatthew Draper <matthew@trebex.net>2016-01-30 03:46:37 +1030
commit74497eabd52f2f9f8c383808b11286283046c2b2 (patch)
treefe2b2cb0d7c4066449fc7e0426d49cad0d2f91e6 /actioncable/lib/action_cable/connection/web_socket.rb
parentc8818dfcdf9e92364745000eefe46132a43f8700 (diff)
downloadrails-74497eabd52f2f9f8c383808b11286283046c2b2.tar.gz
rails-74497eabd52f2f9f8c383808b11286283046c2b2.tar.bz2
rails-74497eabd52f2f9f8c383808b11286283046c2b2.zip
Revert "Revert "Eliminate the EventMachine dependency""
Diffstat (limited to 'actioncable/lib/action_cable/connection/web_socket.rb')
-rw-r--r--actioncable/lib/action_cable/connection/web_socket.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/actioncable/lib/action_cable/connection/web_socket.rb b/actioncable/lib/action_cable/connection/web_socket.rb
index 670d5690ae..5e89fb9b72 100644
--- a/actioncable/lib/action_cable/connection/web_socket.rb
+++ b/actioncable/lib/action_cable/connection/web_socket.rb
@@ -1,13 +1,11 @@
-require 'faye/websocket'
+require 'websocket/driver'
module ActionCable
module Connection
- # Decorate the Faye::WebSocket with helpers we need.
+ # Wrap the real socket to minimize the externally-presented API
class WebSocket
- delegate :rack_response, :close, :on, to: :websocket
-
- def initialize(env)
- @websocket = Faye::WebSocket.websocket?(env) ? Faye::WebSocket.new(env) : nil
+ def initialize(env, event_target, stream_event_loop)
+ @websocket = ::WebSocket::Driver.websocket?(env) ? ClientSocket.new(env, event_target, stream_event_loop) : nil
end
def possible?
@@ -15,11 +13,19 @@ module ActionCable
end
def alive?
- websocket && websocket.ready_state == Faye::WebSocket::API::OPEN
+ websocket && websocket.alive?
end
def transmit(data)
- websocket.send data
+ websocket.transmit data
+ end
+
+ def close
+ websocket.close
+ end
+
+ def rack_response
+ websocket.rack_response
end
protected