diff options
author | Daniel Rhodes <rhodes.daniel@gmail.com> | 2016-03-17 15:05:06 +0100 |
---|---|---|
committer | Daniel Rhodes <rhodes.daniel@gmail.com> | 2016-04-05 15:55:59 +0200 |
commit | cbd15da0274316bae64caae54880fee87853f480 (patch) | |
tree | 9911f491e182ab99d64351438f54e74cf21e24b8 /actioncable/lib/action_cable/connection/faye_client_socket.rb | |
parent | 85119f5909db86167b8b4ed6916b5dda6d9462d5 (diff) | |
download | rails-cbd15da0274316bae64caae54880fee87853f480.tar.gz rails-cbd15da0274316bae64caae54880fee87853f480.tar.bz2 rails-cbd15da0274316bae64caae54880fee87853f480.zip |
Added protocol negotiation
This is primarily for backwards compatibility for when
or if the protocol is changed in future versions.
If the server fails to respond with an acceptable
protocol, the client disconnects and disables
the monitor.
Diffstat (limited to 'actioncable/lib/action_cable/connection/faye_client_socket.rb')
-rw-r--r-- | actioncable/lib/action_cable/connection/faye_client_socket.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/actioncable/lib/action_cable/connection/faye_client_socket.rb b/actioncable/lib/action_cable/connection/faye_client_socket.rb index c9139b6858..09834ca39d 100644 --- a/actioncable/lib/action_cable/connection/faye_client_socket.rb +++ b/actioncable/lib/action_cable/connection/faye_client_socket.rb @@ -3,9 +3,10 @@ require 'faye/websocket' module ActionCable module Connection class FayeClientSocket - def initialize(env, event_target, stream_event_loop) + def initialize(env, event_target, stream_event_loop, protocols) @env = env @event_target = event_target + @protocols = protocols @faye = nil end @@ -23,6 +24,10 @@ module ActionCable @faye && @faye.close end + def protocol + @faye && @faye.protocol + end + def rack_response connect @faye.rack_response @@ -31,7 +36,7 @@ module ActionCable private def connect return if @faye - @faye = Faye::WebSocket.new(@env) + @faye = Faye::WebSocket.new(@env, @protocols) @faye.on(:open) { |event| @event_target.on_open } @faye.on(:message) { |event| @event_target.on_message(event.data) } |