Sha256: a43d165f23b149e84f4154c8184d88380ec6f6b9a735381dd93483bf8f28b210

Contents?: true

Size: 920 Bytes

Versions: 22

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

# :markup: markdown

require "websocket/driver"

module ActionCable
  module Connection
    # # Action Cable Connection WebSocket
    #
    # 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&.alive?
      end

      def transmit(...)
        websocket&.transmit(...)
      end

      def close(...)
        websocket&.close(...)
      end

      def protocol
        websocket&.protocol
      end

      def rack_response
        websocket&.rack_response
      end

      private
        attr_reader :websocket
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
actioncable-7.2.0.beta2 lib/action_cable/connection/web_socket.rb
actioncable-7.2.0.beta1 lib/action_cable/connection/web_socket.rb