Struct Session

Source
pub struct Session { /* private fields */ }
Expand description

The session, that manages the server communication for a character

Implementations§

Source§

impl Session

Source

pub fn new(username: &str, password: &str, server: ServerConnection) -> Self

Constructs a new session for a normal (not SSO) account with the credentials provided. To use this session, you should call login() to actually find out, if the credentials work and to get the initial login response

Source

pub fn new_hashed( username: &str, pw_hash: PWHash, server: ServerConnection, ) -> Self

Does the same as new(), but takes a hashed password directly

Source

pub fn server_url(&self) -> &Url

Returns a reference to the server URL, that this session is sending requests to

Source

pub fn has_session_id(&self) -> bool

Checks if this session has ever been able to successfully login to the server to establish a session id. You should not need to check this, as login() should return error on unsuccessful logins, but if you want to make sure, you can make sure here

Source

pub async fn login(&mut self) -> Result<Response, SFError>

Logges in the session by sending a login response to the server and updating the internal cryptography values. If the session is currently logged in, this also clears the existing state beforehand.

§Errors

Look at send_command() to get a full overview of all the possible errors

Source

pub async fn register( username: &str, password: &str, server: ServerConnection, gender: Gender, race: Race, class: Class, ) -> Result<(Self, Response), SFError>

Registers a new character on the server. If everything works, the logged in character session and its login response will be returned

§Errors

Look at send_command() to get a full overview of all the possible errors

Source

pub async fn send_command_raw<T: Borrow<Command>>( &self, command: T, ) -> Result<Response, SFError>

The internal version send_command(). It allows you to send requests with only a normal ref, because this version does not update the cryptography settings of this session, if the server responds with them. If you do not expect the server to send you new crypto settings, because you only do predictable simple requests (no login, etc), or you want to update them yourself, because that is easier to handle for you, you can use this function to increase your commands/account/sec speed

§Errors

Look at send_command() to get a full overview of all the possible errors

Source

pub async fn send_command<T: Borrow<Command>>( &mut self, command: T, ) -> Result<Response, SFError>

Encode and send a command to the server, decrypts and parses its response and returns the response. When this returns an error, the Session might be in an invalid state, so you should login again just to be safe

§Errors
  • UnsupportedVersion: If error_on_unsupported_version is set and the server is running an unsupported version
  • EmptyResponse: If the servers response was empty
  • InvalidRequest: If your response was invalid to send in some way
  • ConnectionError: If the command could not be send, or the response could not successfully be received
  • ParsingError: If the response from the server was unexpected in some way
  • ServerError: If the server itself responded with an ingame error like “you do not have enough silver to do that”
Source

pub fn update(&mut self, res: &Response)

Manually updates the cryptography setting of this session with the response provided

Source

pub fn username(&self) -> &str

The username of the character, that this session is responsible for

Source

pub async fn renew_sso_creds(&mut self) -> Result<(), SFError>

Retrieves new sso credentials from its sf account. If the account already has new creds stored, these are read, otherwise the account will be logged in again

§Errors
  • InvalidRequest: If you call this function with anything other, than an SSO-Session
  • Other errors, depending on if the session is able to renew the credentials

Trait Implementations§

Source§

impl Clone for Session

Source§

fn clone(&self) -> Session

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T