Sha256: 4215490bc8e95191b0f07c55579a3a0440d2e1c98a0330bfa48d981b9199086d

Contents?: true

Size: 823 Bytes

Versions: 2

Compression:

Stored size: 823 Bytes

Contents

module Rpush
  def self.embed(options = {})
    require 'rpush/daemon'

    if @embed_thread
      STDERR.puts 'Rpush.embed can only be run once inside this process.'
    end

    config = Rpush::ConfigurationWithoutDefaults.new
    options.each { |k, v| config.send("#{k}=", v) }
    config.embedded = true
    config.foreground = true
    Rpush.config.update(config)
    Kernel.at_exit { shutdown }
    @embed_thread = Thread.new { Rpush::Daemon.start }
  end

  def self.shutdown
    return unless Rpush.config.embedded
    Rpush::Daemon.shutdown
    @embed_thread.join if @embed_thread
    @embed_thread = nil
  end

  def self.sync
    return unless Rpush.config.embedded
    Rpush::Daemon::Synchronizer.sync
  end

  def self.debug
    return unless Rpush.config.embedded
    Rpush::Daemon::AppRunner.debug
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpush-2.3.2-java lib/rpush/embed.rb
rpush-2.3.2 lib/rpush/embed.rb