pub struct LicenseActivator {
pub state_recv: Receiver<ActivationState>,
pub error_recv: Receiver<ActivationError>,
pub poll_online_activation: Arc<AtomicBool>,
/* private fields */
}Expand description
Performs license activation.
Fields§
§state_recv: Receiver<ActivationState>Receiver for the main thread to poll changes to the license activation state.
Once ActivationState::Activated has been received, the consumer can stop reading from this channel, as the license activation won’t be revoked again during this session.
Until the first value is received, the license activation state is undetermined, and the user should just be shown a “loading” state.
error_recv: Receiver<ActivationError>Receiver for the main thread to poll errors encountered during license activation.
Which of these you want to display is up to your discretion. You may want to display only the most recent error, or perhaps display each error and make them dismissable.
poll_online_activation: Arc<AtomicBool>While this is true, the license activator polls the Moonbase API to check if the user has activated the license online.
Set this to false whenever the user isn’t on the online activation screen to avoid spamming the Moonbase API and getting rate limited.
Implementations§
Source§impl LicenseActivator
impl LicenseActivator
Sourcepub fn spawn(cfg: LicenseActivationConfig) -> Self
pub fn spawn(cfg: LicenseActivationConfig) -> Self
Creates a new license activator, spawning the background threads that perform license checking.
These background threads run until activation is successful or the LicenseActivator is dropped.
Sourcepub fn machine_file_contents(&self) -> String
pub fn machine_file_contents(&self) -> String
Creates and returns the contents to write to the machine file used for offline activation.
Sourcepub fn submit_offline_activation_token(&mut self, token: &str)
pub fn submit_offline_activation_token(&mut self, token: &str)
Submits the given offline activation token for validation, caching it on disk if it’s valid.
The result of the validation can be obtained from the state and error receivers as usual.