Sha256: 5ab024e7ff549d68d9850a3a54112cd3c182ef232405242d6a539682698dc401

Contents?: true

Size: 884 Bytes

Versions: 3

Compression:

Stored size: 884 Bytes

Contents

module Pakyow
  module Helpers
    # Returns a working realtime context for the current app context.
    #
    # @api public
    def socket
      Realtime::Context.new(self)
    end

    # Returns the session's unique realtime key.
    #
    # @api private
    def socket_key
      return params[:socket_key] if params[:socket_key]
      session[:socket_key] ||= SecureRandom.hex(32)
    end

    # Returns the unique connection id for this request lifecycle.
    #
    # @api private
    def socket_connection_id
      return params[:socket_connection_id] if params[:socket_connection_id]
      @socket_connection_id ||= SecureRandom.hex(32)
    end

    # Returns a digest created from the connection id and socket_key.
    #
    # @api private
    def socket_digest(socket_connection_id)
      Digest::SHA1.hexdigest("--#{socket_key}--#{socket_connection_id}--")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pakyow-realtime-0.10.2 pakyow-realtime/lib/pakyow-realtime/helpers.rb
pakyow-realtime-0.10.1 pakyow-realtime/lib/pakyow-realtime/helpers.rb
pakyow-realtime-0.10.0 pakyow-realtime/lib/pakyow-realtime/helpers.rb