Sha256: 24b955a5b9298cd2954552ac94d09cd19afcc18b2ba9c8517ce7d343fe6df1dc

Contents?: true

Size: 992 Bytes

Versions: 7

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

require "pakyow/realtime/channel"

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

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.6 lib/pakyow/application/helpers/realtime/subscriptions.rb
pakyow-realtime-1.0.5 lib/pakyow/application/helpers/realtime/subscriptions.rb
pakyow-realtime-1.0.4 lib/pakyow/application/helpers/realtime/subscriptions.rb
pakyow-realtime-1.0.3 lib/pakyow/application/helpers/realtime/subscriptions.rb
pakyow-realtime-1.0.2 lib/pakyow/application/helpers/realtime/subscriptions.rb
pakyow-realtime-1.0.1 lib/pakyow/application/helpers/realtime/subscriptions.rb
pakyow-realtime-1.0.0 lib/pakyow/application/helpers/realtime/subscriptions.rb