Class: Satori::RTM::CloseEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/satori-rtm-sdk/model.rb

Overview

Close event with information why connection is closed or can't be established.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, reason) ⇒ CloseEvent

Returns a new instance of CloseEvent


111
112
113
114
# File 'lib/satori-rtm-sdk/model.rb', line 111

def initialize(code, reason)
  @code = code
  @reason = reason
end

Instance Attribute Details

#codeNumber (readonly)

Returns a WebSocket close frame code

Returns:

  • (Number)

    close code

See Also:


108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/satori-rtm-sdk/model.rb', line 108

class CloseEvent
  attr_reader :code, :reason

  def initialize(code, reason)
    @code = code
    @reason = reason
  end

  # Returns +true+ if connection was closed normally
  # @return [Boolean] +true+ if connection was closed normally, +false+ otherwise
  def normal?
    @code == 1000
  end
end

#reasonString (readonly)

Returns a human-readable reason why connection is closed or can't be established.

Returns:

  • (String)

    close reason


108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/satori-rtm-sdk/model.rb', line 108

class CloseEvent
  attr_reader :code, :reason

  def initialize(code, reason)
    @code = code
    @reason = reason
  end

  # Returns +true+ if connection was closed normally
  # @return [Boolean] +true+ if connection was closed normally, +false+ otherwise
  def normal?
    @code == 1000
  end
end

Instance Method Details

#normal?Boolean

Returns true if connection was closed normally

Returns:

  • (Boolean)

    true if connection was closed normally, false otherwise


118
119
120
# File 'lib/satori-rtm-sdk/model.rb', line 118

def normal?
  @code == 1000
end