Class: AppleShove::APNS::WriteExceptionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_shove/apns/write_exception_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ WriteExceptionHandler

Returns a new instance of WriteExceptionHandler.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/apple_shove/apns/write_exception_handler.rb', line 9

def initialize exception

  # defaults

  @message    = "error sending notification: #{exception.class} - #{exception.message}"
  @reconnect  = false
  @rewrite    = false
  @retry      = false

  # known cases

  case exception
  when Errno::EPIPE
    @message    = "broken pipe. reconnecting."
    @reconnect  = true
    @rewrite    = true
    @retry      = true
  when Errno::ETIMEDOUT
    @message    = "timeout. reconnecting."
    @reconnect  = true
    @retry      = true
  when OpenSSL::SSL::SSLError
    if exception.message.match 'bad write retry'
      @message    = "SSL bad write. reconnecting."
      @reconnect  = true
      @retry      = true
    end
  end

end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/apple_shove/apns/write_exception_handler.rb', line 7

def message
  @message
end

Instance Method Details

#reconnect?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/apple_shove/apns/write_exception_handler.rb', line 40

def reconnect?
  @reconnect
end

#retry?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/apple_shove/apns/write_exception_handler.rb', line 48

def retry?
  @retry
end

#rewrite?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/apple_shove/apns/write_exception_handler.rb', line 44

def rewrite?
  @rewrite
end