pub struct ConnectToken {
pub client_id: u64,
pub version_info: [u8; 13],
pub protocol_id: u64,
pub create_timestamp: u64,
pub expire_timestamp: u64,
pub xnonce: [u8; 24],
pub server_addresses: [Option<SocketAddr>; 32],
pub client_to_server_key: [u8; 32],
pub server_to_client_key: [u8; 32],
pub private_data: [u8; 1024],
pub timeout_seconds: i32,
}Available on crate feature
renet_netcode only.Expand description
A public connect token that the client receives to start connecting to the server. How the client receives ConnectToken is up to you, could be from a matchmaking system or from a call to a REST API as an example.
Fields§
§client_id: u64§version_info: [u8; 13]§protocol_id: u64§create_timestamp: u64§expire_timestamp: u64§xnonce: [u8; 24]§server_addresses: [Option<SocketAddr>; 32]§client_to_server_key: [u8; 32]§server_to_client_key: [u8; 32]§private_data: [u8; 1024]§timeout_seconds: i32Implementations§
Source§impl ConnectToken
impl ConnectToken
Sourcepub fn generate(
current_time: Duration,
protocol_id: u64,
expire_seconds: u64,
client_id: u64,
timeout_seconds: i32,
server_addresses: Vec<SocketAddr>,
user_data: Option<&[u8; 256]>,
private_key: &[u8; 32],
) -> Result<ConnectToken, TokenGenerationError>
pub fn generate( current_time: Duration, protocol_id: u64, expire_seconds: u64, client_id: u64, timeout_seconds: i32, server_addresses: Vec<SocketAddr>, user_data: Option<&[u8; 256]>, private_key: &[u8; 32], ) -> Result<ConnectToken, TokenGenerationError>
Generate a token to be sent to an client. The user data is available to the server after an successfull conection. The private key and the protocol id must be the same used in server.
pub fn write(&self, writer: &mut impl Write) -> Result<(), Error>
pub fn read(src: &mut impl Read) -> Result<ConnectToken, NetcodeError>
Trait Implementations§
Source§impl Clone for ConnectToken
impl Clone for ConnectToken
Source§fn clone(&self) -> ConnectToken
fn clone(&self) -> ConnectToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConnectToken
impl Debug for ConnectToken
Source§impl PartialEq for ConnectToken
impl PartialEq for ConnectToken
impl Eq for ConnectToken
impl StructuralPartialEq for ConnectToken
Auto Trait Implementations§
impl Freeze for ConnectToken
impl RefUnwindSafe for ConnectToken
impl Send for ConnectToken
impl Sync for ConnectToken
impl Unpin for ConnectToken
impl UnwindSafe for ConnectToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.