[−][src]Struct rusty_sword_arena::net::ConnectionToServer
This is your client's network connection to the server. The methods abstract away all the actual object serialization and network communication. Hooray for encapsulation!
Methods
impl ConnectionToServer
[src]
pub fn new(host: &str) -> Self
[src]
Create a new connection to a server. host
is the IP address or domain name of the server.
If you run the server on the same machine, you should pass localhost
or 127.0.0.1
as
the host. This neets to be mut
since it needs to track state internally.
pub fn join(&mut self, name: &str) -> Result<u8, String>
[src]
Join a game. If successful, this returns an Ok(u8)
representing your
player id. Save the player id, because it is how you will be able to tell which of the
players the server tells you about later is YOU! If unsuccessful then this returns an
Err(String)
that you can unwrap and print out to see an informative error message.
pub fn get_game_settings(&mut self) -> GameSettings
[src]
Get the current GameSettings
. You should look at the version number and make sure that
you are connecting to a version of the server you expect.
pub fn leave(&mut self, id: u8) -> bool
[src]
Cause the selected player id to leave the game. You should pass in your own player id, obviously. Passing in someone else's player id would be really mean.
pub fn poll_game_states(&mut self) -> Vec<GameState>
[src]
Gets all available unprocessed game states. Game states arrive in order. You should call this every time around your game loop.
pub fn send_player_input(&mut self, player_input: &PlayerInput)
[src]
Send player input to the server. This method only actually sends input to the server if it has been >= 15ms since the last time it sent input (to avoid overwhelming the server with too many input packets per client). Otherwise, it just does nothing. You should maintain a mutable PlayerInput in your game loop and try to send it every time around your loop.
Auto Trait Implementations
impl Send for ConnectionToServer
impl !Sync for ConnectionToServer
impl Unpin for ConnectionToServer
impl UnwindSafe for ConnectionToServer
impl RefUnwindSafe for ConnectionToServer
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,