Sha256: 13b8dd5b2034083ca5cc1e19ba1d66cfa11bd88f1d6a4e26208e9a927f51d629

Contents?: true

Size: 987 Bytes

Versions: 33

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

require "websocket/driver"

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

33 entries across 33 versions & 3 rubygems

Version Path
actioncable-5.2.8.1 lib/action_cable/connection/web_socket.rb
actioncable-5.2.8 lib/action_cable/connection/web_socket.rb
actioncable-5.2.7.1 lib/action_cable/connection/web_socket.rb
actioncable-5.2.7 lib/action_cable/connection/web_socket.rb
actioncable-5.2.6.3 lib/action_cable/connection/web_socket.rb
actioncable-5.2.6.2 lib/action_cable/connection/web_socket.rb
actioncable-5.2.6.1 lib/action_cable/connection/web_socket.rb
actioncable-5.2.6 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.6 lib/action_cable/connection/web_socket.rb
actioncable-5.2.5 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.5 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.4 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.3 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.2 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.1 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4 lib/action_cable/connection/web_socket.rb
actioncable-5.2.4.rc1 lib/action_cable/connection/web_socket.rb
spiral_form-0.1.1 vendor/bundle/gems/actioncable-5.2.3/lib/action_cable/connection/web_socket.rb
spiral_form-0.1.0 vendor/bundle/gems/actioncable-5.2.3/lib/action_cable/connection/web_socket.rb
actioncable-5.2.3 lib/action_cable/connection/web_socket.rb