Struct veloren_server::Server
source · pub struct Server {
pub(crate) state: State,
pub(crate) world: Arc<World>,
pub(crate) index: IndexOwned,
pub(crate) connection_handler: ConnectionHandler,
pub(crate) runtime: Arc<Runtime>,
pub(crate) metrics_registry: Arc<Registry>,
pub(crate) chat_cache: ChatCache,
pub(crate) database_settings: Arc<RwLock<DatabaseSettings>>,
pub(crate) disconnect_all_clients_requested: bool,
pub(crate) server_constants: ServerConstants,
pub(crate) event_dispatcher: SendDispatcher<'static>,
}
Fields§
§state: State
§world: Arc<World>
§index: IndexOwned
§connection_handler: ConnectionHandler
§runtime: Arc<Runtime>
§metrics_registry: Arc<Registry>
§chat_cache: ChatCache
§database_settings: Arc<RwLock<DatabaseSettings>>
§disconnect_all_clients_requested: bool
§server_constants: ServerConstants
§event_dispatcher: SendDispatcher<'static>
Implementations§
source§impl Server
impl Server
fn handle_serial_events<T: Send + 'static, F: FnMut(&mut Self, T)>( &mut self, f: F, )
fn handle_all_serial_events(&mut self, frontend_events: &mut Vec<Event>)
pub fn handle_events(&mut self) -> Vec<Event>
pub fn create_event_dispatcher( pools: Arc<ThreadPool>, ) -> SendDispatcher<'static>
source§impl Server
impl Server
sourcepub fn new(
settings: Settings,
editable_settings: EditableSettings,
database_settings: DatabaseSettings,
data_dir: &Path,
report_stage: &(dyn Fn(ServerInitStage) + Send + Sync),
runtime: Arc<Runtime>,
) -> Result<Self, Error>
pub fn new( settings: Settings, editable_settings: EditableSettings, database_settings: DatabaseSettings, data_dir: &Path, report_stage: &(dyn Fn(ServerInitStage) + Send + Sync), runtime: Arc<Runtime>, ) -> Result<Self, Error>
Create a new Server
pub fn get_server_info(&self) -> ServerInfo
sourcepub fn settings(&self) -> impl Deref<Target = Settings> + '_
pub fn settings(&self) -> impl Deref<Target = Settings> + '_
Get a reference to the server’s settings
sourcepub fn settings_mut(&self) -> impl DerefMut<Target = Settings> + '_
pub fn settings_mut(&self) -> impl DerefMut<Target = Settings> + '_
Get a mutable reference to the server’s settings
sourcepub fn editable_settings_mut(
&self,
) -> impl DerefMut<Target = EditableSettings> + '_
pub fn editable_settings_mut( &self, ) -> impl DerefMut<Target = EditableSettings> + '_
Get a mutable reference to the server’s editable settings
sourcepub fn editable_settings(&self) -> impl Deref<Target = EditableSettings> + '_
pub fn editable_settings(&self) -> impl Deref<Target = EditableSettings> + '_
Get a reference to the server’s editable settings
sourcepub fn data_dir(&self) -> impl Deref<Target = DataDir> + '_
pub fn data_dir(&self) -> impl Deref<Target = DataDir> + '_
Get path to the directory that the server info into
sourcepub fn metrics_registry(&self) -> &Arc<Registry>
pub fn metrics_registry(&self) -> &Arc<Registry>
Get a reference to the Metrics Registry
sourcepub fn chat_cache(&self) -> &ChatCache
pub fn chat_cache(&self) -> &ChatCache
Get a reference to the Chat Cache
pub(crate) fn parse_locations(&self, character_list_data: &mut [CharacterItem])
sourcepub fn tick(&mut self, _input: Input, dt: Duration) -> Result<Vec<Event>, Error>
pub fn tick(&mut self, _input: Input, dt: Duration) -> Result<Vec<Event>, Error>
Execute a single server tick, handle input and update the game state by the given duration.
pub(crate) fn update_region_map(&mut self)
pub(crate) fn initialize_client(&mut self, client: Client) -> Entity
sourcepub(crate) fn disconnect_all_clients_if_requested(
&mut self,
) -> Option<DisconnectType>
pub(crate) fn disconnect_all_clients_if_requested( &mut self, ) -> Option<DisconnectType>
Disconnects all clients if requested by either an admin command or due to a persistence transaction failure and returns the processed DisconnectionType
pub(crate) fn get_disconnect_all_clients_requested( &self, character_updater: &mut CharacterUpdater, ) -> Option<DisconnectType>
sourcepub(crate) fn handle_new_connections(
&mut self,
frontend_events: &mut Vec<Event>,
)
pub(crate) fn handle_new_connections( &mut self, frontend_events: &mut Vec<Event>, )
Handle new client connections.
pub fn notify_client<S>(&self, entity: EcsEntity, msg: S)where
S: Into<ServerMsg>,
pub fn notify_players(&mut self, msg: ServerGeneral)
pub fn generate_chunk(&mut self, entity: EcsEntity, key: Vec2<i32>)
pub(crate) fn process_command( &mut self, entity: EcsEntity, name: String, args: Vec<String>, )
pub(crate) fn entity_admin_role(&self, entity: EcsEntity) -> Option<AdminRole>
pub fn number_of_players(&self) -> i64
sourcepub fn add_admin(&mut self, username: &str, role: AdminRole)
pub fn add_admin(&mut self, username: &str, role: AdminRole)
NOTE: Do not allow this to be called from any command that doesn’t go through the CLI!
sourcepub fn remove_admin(&self, username: &str)
pub fn remove_admin(&self, username: &str)
NOTE: Do not allow this to be called from any command that doesn’t go through the CLI!
sourcepub fn create_centered_persister(&mut self, view_distance: u32)
pub fn create_centered_persister(&mut self, view_distance: u32)
Useful for testing without a client view_distance: distance in chunks that are persisted, this acts like the player view distance so it is actually a bit farther due to a buffer zone
sourcepub fn chunks_pending(&mut self) -> bool
pub fn chunks_pending(&mut self) -> bool
Used by benchmarking code.
sourcepub fn set_sql_log_mode(&mut self, sql_log_mode: SqlLogMode)
pub fn set_sql_log_mode(&mut self, sql_log_mode: SqlLogMode)
Sets the SQL log mode at runtime
pub fn disconnect_all_clients(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl !Sync for Server
impl !Unpin for Server
impl !UnwindSafe for Server
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Pointee for T
impl<T> Pointee for T
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.