Class: Rpush::Daemon::Dispatcher::ApnsTcp

Inherits:
Tcp
  • Object
show all
Includes:
Loggable, Reflectable
Defined in:
lib/rpush/daemon/dispatcher/apns_tcp.rb

Constant Summary collapse

SELECT_TIMEOUT =
10
ERROR_TUPLE_BYTES =
6
APNS_ERRORS =
{
  1 => 'Processing error',
  2 => 'Missing device token',
  3 => 'Missing topic',
  4 => 'Missing payload',
  5 => 'Missing token size',
  6 => 'Missing topic size',
  7 => 'Missing payload size',
  8 => 'Invalid token',
  255 => 'None (unknown error)'
}

Instance Method Summary collapse

Methods included from Reflectable

#reflect

Methods included from Loggable

#log_error, #log_info, #log_warn

Constructor Details

#initialize(*args) ⇒ ApnsTcp

Returns a new instance of ApnsTcp.



22
23
24
25
26
27
# File 'lib/rpush/daemon/dispatcher/apns_tcp.rb', line 22

def initialize(*args)
  super
  @dispatch_mutex = Mutex.new
  @stop_error_receiver = false
  @connection.on_connect { start_error_receiver }
end

Instance Method Details

#cleanupObject



36
37
38
39
40
# File 'lib/rpush/daemon/dispatcher/apns_tcp.rb', line 36

def cleanup
  @stop_error_receiver = true
  super
  @error_receiver_thread.join if @error_receiver_thread
end

#dispatch(payload) ⇒ Object



29
30
31
32
33
34
# File 'lib/rpush/daemon/dispatcher/apns_tcp.rb', line 29

def dispatch(payload)
  @dispatch_mutex.synchronize do
    @delivery_class.new(@app, @connection, payload.batch).perform
    record_batch(payload.batch)
  end
end