Class: Lapis::Yggdrasil::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/lapis/yggdrasil/session.rb

Overview

Manages state information and transitioning for a session.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info, client) ⇒ Session

Creates a new session. The session still needs to be authenticated after initialization.

Parameters:



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

#infoSessionInfo (readonly)

Information about the current session.

Returns:



10
11
12
# File 'lib/lapis/yggdrasil/session.rb', line 10

def info
  @info
end

#valid?Boolean (readonly)

Returns:

  • (Boolean)


16
17
18
# File 'lib/lapis/yggdrasil/session.rb', line 16

def valid?
  @is_valid &&= validate
end

Instance Method Details

#invalidatevoid

This method returns an undefined value.

Marks the session as not valid.

Raises:



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.

Parameters:

  • profile (Profile, nil) (defaults to: nil)

    Profile to switch to. Set to nil to keep the current profile.

Returns:

Raises:



37
38
39
# File 'lib/lapis/yggdrasil/session.rb', line 37

def refresh(profile = nil)
  @info = @client.refresh(@info, profile)
end

#validatetrue, false

Checks that the session is still valid.

Returns:

  • (true)

    The session is still valid.

  • (false)

    The session is no longer valid.

Raises:



45
46
47
# File 'lib/lapis/yggdrasil/session.rb', line 45

def validate
  @client.validate(@info)
end