Class: Discordrb::Session
- Inherits:
-
Object
- Object
- Discordrb::Session
- Defined in:
- lib/discordrb/gateway.rb
Overview
This class stores the data of an active gateway session. Note that this is different from a websocket connection - there may be multiple sessions per connection or one session may persist over multiple connections.
Instance Attribute Summary collapse
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
Instance Method Summary collapse
-
#initialize(session_id) ⇒ Session
constructor
A new instance of Session.
- #invalid? ⇒ Boolean
-
#invalidate ⇒ Object
Flags this session as being invalid.
-
#resume ⇒ Object
Flags this session as no longer being suspended, so we can resume.
- #should_resume? ⇒ Boolean
-
#suspend ⇒ Object
Flags this session as suspended, so we know not to try and send heartbeats, etc.
- #suspended? ⇒ Boolean
Constructor Details
#initialize(session_id) ⇒ Session
Returns a new instance of Session.
96 97 98 99 100 101 |
# File 'lib/discordrb/gateway.rb', line 96 def initialize(session_id) @session_id = session_id @sequence = 0 @suspended = false @invalid = false end |
Instance Attribute Details
#sequence ⇒ Object
Returns the value of attribute sequence.
94 95 96 |
# File 'lib/discordrb/gateway.rb', line 94 def sequence @sequence end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
93 94 95 |
# File 'lib/discordrb/gateway.rb', line 93 def session_id @session_id end |
Instance Method Details
#invalid? ⇒ Boolean
122 123 124 |
# File 'lib/discordrb/gateway.rb', line 122 def invalid? @invalid end |
#invalidate ⇒ Object
Flags this session as being invalid
118 119 120 |
# File 'lib/discordrb/gateway.rb', line 118 def invalidate @invalid = true end |
#resume ⇒ Object
Flags this session as no longer being suspended, so we can resume
113 114 115 |
# File 'lib/discordrb/gateway.rb', line 113 def resume @suspended = false end |
#should_resume? ⇒ Boolean
126 127 128 |
# File 'lib/discordrb/gateway.rb', line 126 def should_resume? suspended? && !invalid? end |
#suspend ⇒ Object
Flags this session as suspended, so we know not to try and send heartbeats, etc. to the gateway until we've reconnected
104 105 106 |
# File 'lib/discordrb/gateway.rb', line 104 def suspend @suspended = true end |
#suspended? ⇒ Boolean
108 109 110 |
# File 'lib/discordrb/gateway.rb', line 108 def suspended? @suspended end |