Sha256: d8ff643f5f2df4451dea608202d5866a6bde7359415076896c8db47943ff7855

Contents?: true

Size: 842 Bytes

Versions: 5

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require "pakyow/realtime/channel"

module Pakyow
  module Realtime
    module Helpers
      module Subscriptions
        def subscribe(channel, *qualifiers)
          channels = if qualifiers.empty?
            Channel.new(channel)
          else
            qualifiers.map { |qualifier|
              Channel.new(channel, qualifier)
            }
          end

          app.websocket_server.socket_subscribe(socket_client_id, *channels)
        end

        def unsubscribe(channel, *qualifiers)
          channels = if qualifiers.empty?
            Channel.new(channel, "*")
          else
            qualifiers.map { |qualifier|
              Channel.new(channel, qualifier)
            }
          end

          app.websocket_server.socket_unsubscribe(*channels)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.0.rc5 lib/pakyow/realtime/helpers/subscriptions.rb
pakyow-realtime-1.0.0.rc4 lib/pakyow/realtime/helpers/subscriptions.rb
pakyow-realtime-1.0.0.rc3 lib/pakyow/realtime/helpers/subscriptions.rb
pakyow-realtime-1.0.0.rc2 lib/pakyow/realtime/helpers/subscriptions.rb
pakyow-realtime-1.0.0.rc1 lib/pakyow/realtime/helpers/subscriptions.rb