Sha256: 5ce95933e928114a8bdea58edfdfd2fa7fcb9282af5a0e0b4f809277ccf0b3f1

Contents?: true

Size: 734 Bytes

Versions: 2

Compression:

Stored size: 734 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(notification, batch)
          @delivery_class.new(@app, connection, notification, batch).perform
        end

        def cleanup
          @connection.close if @connection
        end

        private

        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

2 entries across 2 versions & 1 rubygems

Version Path
rpush-1.0.0-java lib/rpush/daemon/dispatcher/tcp.rb
rpush-1.0.0 lib/rpush/daemon/dispatcher/tcp.rb