Sha256: b48e3a0add6676be22e2c3005c7ce8dceb8dba3e41d8cd6d093bc75023942c24

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

# :markup: markdown

require "websocket/driver"

module ActionCable
  module Server
    class Socket
      # # 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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
actioncable-next-0.2.0 lib/action_cable/server/socket/web_socket.rb
actioncable-next-0.1.2 lib/action_cable/server/socket/web_socket.rb
actioncable-next-0.1.1 lib/action_cable/server/socket/web_socket.rb
actioncable-next-0.1.0 lib/action_cable/server/socket/web_socket.rb