pub struct Controller { /* private fields */ }Expand description
§Functionality:
- Connection controller
- Provides information to connector
- Handles client connections to the game
Implementations§
Source§impl Controller
impl Controller
Sourcepub fn open_game_port<'de, T, K, I, M>(
port: i32,
max_players: i32,
connector: Arc<Mutex<Connector>>,
handle_input: &'static (dyn Fn(Receiver<(M, usize)>, Arc<Mutex<I>>) -> I + Sync),
app: Application<T, K, I>,
send_data_rate: i32,
)
pub fn open_game_port<'de, T, K, I, M>( port: i32, max_players: i32, connector: Arc<Mutex<Connector>>, handle_input: &'static (dyn Fn(Receiver<(M, usize)>, Arc<Mutex<I>>) -> I + Sync), app: Application<T, K, I>, send_data_rate: i32, )
What it does:
- Runs a game (application).
- Creates messaging channel between controller and app.
- Creates a shared state to share between app and client.
- Opens a port for game.
Sourcepub fn handle_player_connection<'de, K, M>(
stream: TcpStream,
game: Arc<Mutex<Controller>>,
id: usize,
sender: Sender<(M, usize)>,
shared_state: Arc<Mutex<K>>,
send_data_rate: i32,
) -> Result<(), Error>
pub fn handle_player_connection<'de, K, M>( stream: TcpStream, game: Arc<Mutex<Controller>>, id: usize, sender: Sender<(M, usize)>, shared_state: Arc<Mutex<K>>, send_data_rate: i32, ) -> Result<(), Error>
Handles player writing and reading
Sourcepub fn add_player(&mut self) -> (bool, usize)
pub fn add_player(&mut self) -> (bool, usize)
Add a player to the game
Sourcepub fn remove_player(&mut self, index: usize) -> bool
pub fn remove_player(&mut self, index: usize) -> bool
Remove a player from the game
Auto Trait Implementations§
impl Freeze for Controller
impl RefUnwindSafe for Controller
impl Send for Controller
impl Sync for Controller
impl Unpin for Controller
impl UnwindSafe for Controller
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