Expand description
A websocket server for Voxelize, holds all worlds data, and runs as a background system service.
Fields
port: u16
The port that this voxelize server is running on.
addr: String
The address that this voxelize server is running on.
started: bool
Whether or not if the socket server has started as a system service.
Implementations
sourceimpl Server
impl Server
sourcepub fn new() -> ServerBuilder
pub fn new() -> ServerBuilder
Create a new Voxelize server instance used to host all the worlds.
Example
// Create a server of port 4000 on "0.0.0.0"
let server = Server::new().addr("0.0.0.0").port(4000).build();
// Run the server on Voxelize
Voxelize::run(server);
sourcepub fn set_handler(&mut self, handler: NodeHandler<()>)
pub fn set_handler(&mut self, handler: NodeHandler<()>)
Assign a network handler to this server
sourcepub fn add_endpoint(&mut self, endpoint: Endpoint)
pub fn add_endpoint(&mut self, endpoint: Endpoint)
Add an endpoint, without assigning them to a world. Endpoint(client) needs to pass a CONNECT
type
protocol buffer with a world name to be assigned to a world.
sourcepub fn add_world(&mut self, world: World) -> Result<&mut World, AddWorldError>
pub fn add_world(&mut self, world: World) -> Result<&mut World, AddWorldError>
Add a world instance to the server. Different worlds have different configurations, and can hold their own set of clients within. If the server has already started, the added world will be started right away.
sourcepub fn create_world(
&mut self,
name: &str,
config: &WorldConfig
) -> Result<&mut World, AddWorldError>
pub fn create_world(
&mut self,
name: &str,
config: &WorldConfig
) -> Result<&mut World, AddWorldError>
Create a world in the server. Different worlds have different configurations, and can hold their own set of clients within. If the server has already started, the added world will be started right away.
sourcepub fn get_world_mut(&mut self, world_name: &str) -> Option<&mut World>
pub fn get_world_mut(&mut self, world_name: &str) -> Option<&mut World>
Get a mutable world reference by name.
pub fn broadcast(&self, data: Message)
sourcepub fn on_request(&mut self, endpoint: Endpoint, data: Message)
pub fn on_request(&mut self, endpoint: Endpoint, data: Message)
Handler for client’s message.
sourcepub fn handler(&self) -> &NodeHandler<()>
pub fn handler(&self) -> &NodeHandler<()>
Obtain the network handler.
pub fn tick(&mut self)
Auto Trait Implementations
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations
impl<T> Any for T where
T: Any,
impl<T> Any for T where
T: Any,
fn get_type_id(&self) -> TypeId
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more