Sha256: 0239d5e4e75230a52f5591b5ce1e4cb0d0c52584101c3157e1eb29ef7aef2617

Contents?: true

Size: 740 Bytes

Versions: 12

Compression:

Stored size: 740 Bytes

Contents

module Rpush
  module Daemon
    module Dispatcher
      class Tcp
        def initialize(app, delivery_class, options = {})
          @app = app
          @delivery_class = delivery_class
          @host, @port = options[:host].call(@app)
        end

        def dispatch(payload)
          @delivery_class.new(@app, connection, payload.notification, payload.batch).perform
        end

        def cleanup
          @connection.close if @connection
        end

        protected

        def connection
          return @connection if defined? @connection
          connection = Rpush::Daemon::TcpConnection.new(@app, @host, @port)
          connection.connect
          @connection = connection
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rpush-2.2.0-java lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.2.0 lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.1.0-java lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.1.0 lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.1-java lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.1 lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.0-java lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.0 lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.0.rc1-java lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.0.rc1 lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.0.beta2 lib/rpush/daemon/dispatcher/tcp.rb
rpush-2.0.0.beta1 lib/rpush/daemon/dispatcher/tcp.rb