Sha256: d03d5ef216a62bf92a47d7b947af2558d513979d73c4144bc4b0dd9edd767d13

Contents?: true

Size: 946 Bytes

Versions: 20

Compression:

Stored size: 946 Bytes

Contents

require "websocket/driver"

module ActionCable
  module Connection
    # Wrap the real socket to minimize the externally-presented API
    class WebSocket
      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

      def possible?
        websocket
      end

      def alive?
        websocket && websocket.alive?
      end

      def transmit(data)
        websocket.transmit data
      end

      def close
        websocket.close
      end

      def protocol
        websocket.protocol
      end

      def rack_response
        websocket.rack_response
      end

      # TODO Change this to private once we've dropped Ruby 2.2 support.
      # Workaround for Ruby 2.2 "private attribute?" warning.
      protected
        attr_reader :websocket
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
actioncable-5.1.7 lib/action_cable/connection/web_socket.rb
actioncable-5.1.7.rc1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.6.2 lib/action_cable/connection/web_socket.rb
actioncable-5.1.6.1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.6 lib/action_cable/connection/web_socket.rb
actioncable-5.1.5 lib/action_cable/connection/web_socket.rb
actioncable-5.1.5.rc1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.4 lib/action_cable/connection/web_socket.rb
actioncable-5.1.4.rc1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.3 lib/action_cable/connection/web_socket.rb
actioncable-5.1.3.rc3 lib/action_cable/connection/web_socket.rb
actioncable-5.1.3.rc2 lib/action_cable/connection/web_socket.rb
actioncable-5.1.3.rc1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.2 lib/action_cable/connection/web_socket.rb
actioncable-5.1.2.rc1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.0 lib/action_cable/connection/web_socket.rb
actioncable-5.1.0.rc2 lib/action_cable/connection/web_socket.rb
actioncable-5.1.0.rc1 lib/action_cable/connection/web_socket.rb
actioncable-5.1.0.beta1 lib/action_cable/connection/web_socket.rb