Class: Rpush::Daemon::Dispatcher::Tcp

Inherits:
Object
  • Object
show all
Defined in:
lib/rpush/daemon/dispatcher/tcp.rb

Direct Known Subclasses

ApnsTcp

Instance Method Summary collapse

Constructor Details

#initialize(app, delivery_class, options = {}) ⇒ Tcp

Returns a new instance of Tcp


5
6
7
8
9
10
# File 'lib/rpush/daemon/dispatcher/tcp.rb', line 5

def initialize(app, delivery_class, options = {})
  @app = app
  @delivery_class = delivery_class
  @host, @port = options[:host].call(@app)
  @connection = Rpush::Daemon::TcpConnection.new(@app, @host, @port)
end

Instance Method Details

#cleanupObject


16
17
18
# File 'lib/rpush/daemon/dispatcher/tcp.rb', line 16

def cleanup
  @connection.close if @connection
end

#dispatch(payload) ⇒ Object


12
13
14
# File 'lib/rpush/daemon/dispatcher/tcp.rb', line 12

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