Struct racetime::handler::RaceContext
source · pub struct RaceContext<S: Send + Sync + ?Sized + 'static> {
pub global_state: Arc<S>,
pub sender: Arc<Mutex<WsSink>>,
/* private fields */
}
Expand description
A type passed to RaceHandler
callback methods which can be used to check the current status of the race or send messages.
Fields§
§global_state: Arc<S>
§sender: Arc<Mutex<WsSink>>
Implementations§
source§impl<S: Send + Sync + ?Sized + 'static> RaceContext<S>
impl<S: Send + Sync + ?Sized + 'static> RaceContext<S>
sourcepub async fn data(&self) -> RwLockReadGuard<'_, RaceData>
pub async fn data(&self) -> RwLockReadGuard<'_, RaceData>
Returns the current state of the race.
sourcepub async fn send_raw(&self, message: &Json) -> Result<(), Error>
pub async fn send_raw(&self, message: &Json) -> Result<(), Error>
Sends a raw JSON message to the server.
The methods set_raceinfo
through remove_monitor
should be preferred.
sourcepub async fn send_message(&self, message: &str) -> Result<(), Error>
pub async fn send_message(&self, message: &str) -> Result<(), Error>
Send a chat message to the race room.
message
should be the message string you want to send.
sourcepub async fn set_bot_raceinfo(&self, info: &str) -> Result<(), Error>
pub async fn set_bot_raceinfo(&self, info: &str) -> Result<(), Error>
Set the info_bot
field on the race room’s data.
sourcepub async fn set_user_raceinfo(
&self,
info: &str,
pos: RaceInfoPos
) -> Result<(), Error>
pub async fn set_user_raceinfo(
&self,
info: &str,
pos: RaceInfoPos
) -> Result<(), Error>
Set the info_user
field on the race room’s data.
info
should be the information you wish to set, and pos
the behavior in case there is existing info.
sourcepub async fn set_invitational(&self) -> Result<(), Error>
pub async fn set_invitational(&self) -> Result<(), Error>
Set the room in an invite-only state.
sourcepub async fn force_start(&self) -> Result<(), Error>
pub async fn force_start(&self) -> Result<(), Error>
Forces a start of the race.
sourcepub async fn cancel_race(&self) -> Result<(), Error>
pub async fn cancel_race(&self) -> Result<(), Error>
Forcibly cancels a race.
sourcepub async fn invite_user(&self, user: &str) -> Result<(), Error>
pub async fn invite_user(&self, user: &str) -> Result<(), Error>
Invites a user to the race.
user
should be the hashid of the user.
sourcepub async fn accept_request(&self, user: &str) -> Result<(), Error>
pub async fn accept_request(&self, user: &str) -> Result<(), Error>
Accepts a request to join the race room.
user
should be the hashid of the user.
sourcepub async fn force_unready(&self, user: &str) -> Result<(), Error>
pub async fn force_unready(&self, user: &str) -> Result<(), Error>
Forcibly unreadies an entrant.
user
should be the hashid of the user.
sourcepub async fn remove_entrant(&self, user: &str) -> Result<(), Error>
pub async fn remove_entrant(&self, user: &str) -> Result<(), Error>
Forcibly removes an entrant from the race.
user
should be the hashid of the user.