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
-
#resume_gateway_url ⇒ String
readonly
Gateway URL used to reconnect to the gateway node that Discord wants this session to use.
-
#sequence ⇒ Integer
Incrementing integer used to determine the most recent event reccived from Discord.
-
#session_id ⇒ String
readonly
Used to uniquely identify this session.
Instance Method Summary collapse
- #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
Instance Attribute Details
#resume_gateway_url ⇒ String (readonly)
Returns Gateway URL used to reconnect to the gateway node that Discord wants this session to use.
100 101 102 |
# File 'lib/discordrb/gateway.rb', line 100 def resume_gateway_url @resume_gateway_url end |
#sequence ⇒ Integer
Returns Incrementing integer used to determine the most recent event reccived from Discord.
97 98 99 |
# File 'lib/discordrb/gateway.rb', line 97 def sequence @sequence end |
#session_id ⇒ String (readonly)
Returns Used to uniquely identify this session. Mostly used when resuming connections.
94 95 96 |
# File 'lib/discordrb/gateway.rb', line 94 def session_id @session_id end |
Instance Method Details
#invalid? ⇒ Boolean
131 132 133 |
# File 'lib/discordrb/gateway.rb', line 131 def invalid? @invalid end |
#invalidate ⇒ Object
Flags this session as being invalid
126 127 128 129 |
# File 'lib/discordrb/gateway.rb', line 126 def invalidate @invalid = true @resume_gateway_url = nil end |
#resume ⇒ Object
Flags this session as no longer being suspended, so we can resume
121 122 123 |
# File 'lib/discordrb/gateway.rb', line 121 def resume @suspended = false end |
#should_resume? ⇒ Boolean
135 136 137 |
# File 'lib/discordrb/gateway.rb', line 135 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
112 113 114 |
# File 'lib/discordrb/gateway.rb', line 112 def suspend @suspended = true end |
#suspended? ⇒ Boolean
116 117 118 |
# File 'lib/discordrb/gateway.rb', line 116 def suspended? @suspended end |