pub trait ServerContext: Send + Sync {
// Required methods
fn emit_event<'life0, 'async_trait>(
&'life0 self,
namespace: EventNamespace,
event: Box<dyn GameEvent>,
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn region_id(&self) -> RegionId;
fn get_players<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Player>, ServerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_player<'life0, 'async_trait>(
&'life0 self,
id: PlayerId,
) -> Pin<Box<dyn Future<Output = Result<Option<Player>, ServerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send_to_player<'life0, 'life1, 'async_trait>(
&'life0 self,
player_id: PlayerId,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn broadcast_to_region<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn log(&self, level: LogLevel, message: &str);
}
Expand description
Server context provided to plugins
Required Methods§
Sourcefn emit_event<'life0, 'async_trait>(
&'life0 self,
namespace: EventNamespace,
event: Box<dyn GameEvent>,
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn emit_event<'life0, 'async_trait>(
&'life0 self,
namespace: EventNamespace,
event: Box<dyn GameEvent>,
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Emit an event to the event system
Sourcefn get_players<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Player>, ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_players<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Player>, ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all players in the region
Sourcefn get_player<'life0, 'async_trait>(
&'life0 self,
id: PlayerId,
) -> Pin<Box<dyn Future<Output = Result<Option<Player>, ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_player<'life0, 'async_trait>(
&'life0 self,
id: PlayerId,
) -> Pin<Box<dyn Future<Output = Result<Option<Player>, ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get specific player by ID
Sourcefn send_to_player<'life0, 'life1, 'async_trait>(
&'life0 self,
player_id: PlayerId,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_to_player<'life0, 'life1, 'async_trait>(
&'life0 self,
player_id: PlayerId,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send message to specific player
Sourcefn broadcast_to_region<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn broadcast_to_region<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), ServerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Broadcast message to all players in region