pub trait Communicatorwhere
Self: Sized,{
Show 15 methods
// Required methods
async fn on_match_abrupt_close<F, Fut>(&self, callback: F)
where F: MessageHandler<MatchAbrubtClose, Fut>,
Fut: Future<Output = ()> + Send + Sync + 'static;
async fn on_match_result<F, Fut>(&self, callback: F)
where F: MessageHandler<MatchResult, Fut>,
Fut: Future<Output = ()> + Send + Sync + 'static;
async fn on_match_created<F, Fut>(&self, callback: F)
where F: MessageHandler<CreatedMatch, Fut>,
Fut: Future<Output = ()> + Send + Sync + 'static;
async fn on_game_create<F, Fut>(&self, callback: F)
where F: MessageHandler<GameServerCreate, Fut>,
Fut: Future<Output = String> + Send + Sync + 'static;
async fn on_health_check<F, Fut>(&self, callback: F)
where F: MessageHandler<String, Fut>,
Fut: Future<Output = ()> + Send + Sync + 'static;
async fn on_match_create<F, Fut>(&self, callback: F)
where F: MessageHandler<CreateMatch, Fut>,
Fut: Future<Output = ()> + Send + Sync + 'static;
async fn on_ai_register<F, Fut>(&self, callback: F)
where F: MessageHandler<AIPlayerRegister, Fut>,
Fut: Future<Output = ()> + Send + Sync + 'static;
async fn create_game(
&self,
game_server: &GameServerCreate,
) -> Result<String, Box<dyn Error>>;
async fn send_health_check(&self, client_id: String);
async fn create_match(&self, match_request: &CreateMatch);
async fn report_match_created(&self, created_match: &CreatedMatch);
async fn report_match_result(&self, match_result: &MatchResult);
async fn report_match_abrupt_close(&self, match_close: &MatchAbrubtClose);
async fn create_ai_task(&self, task: &Task);
async fn register_ai_player(&self, ai_player: &AIPlayerRegister);
}Expand description
Handles communication between the game server and the matchmaker. Structs which implement the Communicator trait enable multi-device communication. This means that if a callback is registered with an “on”-function, it may be called when any device calls a “report” or “send” function.
Required Methods§
Sourceasync fn on_match_abrupt_close<F, Fut>(&self, callback: F)
async fn on_match_abrupt_close<F, Fut>(&self, callback: F)
Registers a callback for when a match is abruptly closed.
§Arguments
callback- A function that handlesMatchAbrubtCloseevents.
Sourceasync fn on_match_result<F, Fut>(&self, callback: F)
async fn on_match_result<F, Fut>(&self, callback: F)
Registers a callback for when a match result is reported.
§Arguments
callback- A function that handlesMatchResultevents.
Sourceasync fn on_match_created<F, Fut>(&self, callback: F)
async fn on_match_created<F, Fut>(&self, callback: F)
Registers a callback for when a match is created.
§Arguments
callback- A function that handlesCreatedMatchevents.
Sourceasync fn on_game_create<F, Fut>(&self, callback: F)where
F: MessageHandler<GameServerCreate, Fut>,
Fut: Future<Output = String> + Send + Sync + 'static,
async fn on_game_create<F, Fut>(&self, callback: F)where
F: MessageHandler<GameServerCreate, Fut>,
Fut: Future<Output = String> + Send + Sync + 'static,
Registers a callback for when a game server is created.
§Arguments
callback- A function that handlesGameServerCreateevents.
Sourceasync fn on_health_check<F, Fut>(&self, callback: F)
async fn on_health_check<F, Fut>(&self, callback: F)
Registers a callback for health check events.
§Arguments
callback- A function that handles health check events.
Sourceasync fn on_match_create<F, Fut>(&self, callback: F)
async fn on_match_create<F, Fut>(&self, callback: F)
Registers a callback for when a match creation request is received.
§Arguments
callback- A function that handlesCreateMatchevents.
Sourceasync fn on_ai_register<F, Fut>(&self, callback: F)
async fn on_ai_register<F, Fut>(&self, callback: F)
Registers a callback for when a new ai-player is registered.
§Arguments
callback- A function that handlesAIPlayerRegisterevents.
Sourceasync fn create_game(
&self,
game_server: &GameServerCreate,
) -> Result<String, Box<dyn Error>>
async fn create_game( &self, game_server: &GameServerCreate, ) -> Result<String, Box<dyn Error>>
Sourceasync fn send_health_check(&self, client_id: String)
async fn send_health_check(&self, client_id: String)
Sends a health check to the specified client.
§Arguments
client_id- The ID of the client to send the health check to.
Sourceasync fn create_match(&self, match_request: &CreateMatch)
async fn create_match(&self, match_request: &CreateMatch)
Creates a match based on the provided match request.
§Arguments
match_request- The match creation request.
Sourceasync fn report_match_created(&self, created_match: &CreatedMatch)
async fn report_match_created(&self, created_match: &CreatedMatch)
Sourceasync fn report_match_result(&self, match_result: &MatchResult)
async fn report_match_result(&self, match_result: &MatchResult)
Sourceasync fn report_match_abrupt_close(&self, match_close: &MatchAbrubtClose)
async fn report_match_abrupt_close(&self, match_close: &MatchAbrubtClose)
Reports that a match was abruptly closed.
§Arguments
match_close- The abrupt match close information.
Sourceasync fn create_ai_task(&self, task: &Task)
async fn create_ai_task(&self, task: &Task)
Sourceasync fn register_ai_player(&self, ai_player: &AIPlayerRegister)
async fn register_ai_player(&self, ai_player: &AIPlayerRegister)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.