Sha256: ea11eaacd37b272e19626ce476c757408755ae78c55d24fc39ed5093507539cb

Contents?: true

Size: 900 Bytes

Versions: 2

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

module Pakyow
  module Realtime
    # Deals with realtime connections in context of an app. Instances are
    # returned by the `socket` helper method during routing.
    #
    # @api public
    class Context
      # @api private
      def initialize(app)
        @app = app
      end

      # Push a message down one or more channels.
      #
      # @api public
      def push(msg, *channels)
        delegate.push(msg, *channels)
      end

      # Push a message down a channel directed at a specific client,
      # identified by key.
      #
      # @api public
      def push_to_key(msg, channel, key, propagated: false)
        delegate.push_to_key(msg, channel, key, propagated: propagated)
      end

      # Returns an instance of the connection delegate.
      #
      # @api private
      def delegate
        Delegate.instance
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.0.rc2 lib/pakyow/realtime/context.rb
pakyow-realtime-1.0.0.rc1 lib/pakyow/realtime/context.rb