Class: Lapis::Yggdrasil::Session
- Inherits:
-
Object
- Object
- Lapis::Yggdrasil::Session
- Defined in:
- lib/lapis/yggdrasil/session.rb
Overview
Manages state information and transitioning for a session.
Instance Attribute Summary collapse
-
#info ⇒ SessionInfo
readonly
Information about the current session.
- #valid? ⇒ Boolean readonly
Instance Method Summary collapse
-
#initialize(info, client) ⇒ Session
constructor
Creates a new session.
-
#invalidate ⇒ void
Marks the session as not valid.
-
#refresh(profile = nil) ⇒ SessionInfo
Refresh the session so it can be used again.
-
#validate ⇒ true, false
Checks that the session is still valid.
Constructor Details
#initialize(info, client) ⇒ Session
Creates a new session. The session still needs to be authenticated after initialization.
24 25 26 27 28 |
# File 'lib/lapis/yggdrasil/session.rb', line 24 def initialize(info, client) @info = info @client = client @is_valid = true end |
Instance Attribute Details
#info ⇒ SessionInfo (readonly)
Information about the current session.
10 11 12 |
# File 'lib/lapis/yggdrasil/session.rb', line 10 def info @info end |
#valid? ⇒ Boolean (readonly)
16 17 18 |
# File 'lib/lapis/yggdrasil/session.rb', line 16 def valid? @is_valid &&= validate end |
Instance Method Details
#invalidate ⇒ void
This method returns an undefined value.
Marks the session as not valid.
52 53 54 55 |
# File 'lib/lapis/yggdrasil/session.rb', line 52 def invalidate @client.invalidate(@info) @is_valid = false end |
#refresh(profile = nil) ⇒ SessionInfo
Note:
Setting profile
to anything other than nil
will result in an error. In the current version of Yggdrasil, switching profiles is not supported.
Refresh the session so it can be used again.
37 38 39 |
# File 'lib/lapis/yggdrasil/session.rb', line 37 def refresh(profile = nil) @info = @client.refresh(@info, profile) end |
#validate ⇒ true, false
Checks that the session is still valid.
45 46 47 |
# File 'lib/lapis/yggdrasil/session.rb', line 45 def validate @client.validate(@info) end |