pub struct Server<P: ProtocolType, E: Copy + Eq + Hash> { /* private fields */ }
Expand description

A server that uses either UDP or WebRTC communication to send/receive messages to/from connected clients, and syncs registered entities to clients to whom they are in-scope

Implementations

Create a new Server

Listen at the given addresses

Returns whether or not the Server has initialized correctly and is listening for Clients

Must be called regularly, maintains connection to and receives messages from all Clients

Accepts an incoming Client User, allowing them to establish a connection with the Server

Rejects an incoming Client User, terminating their attempt to establish a connection with the Server

Queues up an Message to be sent to the Client associated with a given UserKey

Used to evaluate whether, given a User & Entity that are in the same Room, said Entity should be in scope for the given User.

While Rooms allow for a very simple scope to which an Entity can belong, this provides complete customization for advanced scopes.

Return a collection of Entity Scope Sets, being a unique combination of a related Room, User, and Entity, used to determine which Entities to replicate to which Users

Sends all update messages to all Clients. If you don’t call this method, the Server will never communicate with it’s connected Clients

Creates a new Entity and returns an EntityMut which can be used for further operations on the Entity

Creates a new Entity with a specific id

Retrieves an EntityRef that exposes read-only operations for the Entity. Panics if the Entity does not exist.

Retrieves an EntityMut that exposes read and write operations for the Entity. Panics if the Entity does not exist.

Retrieves a WorldlessEntityMut that exposes read and write operations on the Entity, but with no references allowed to the World. This is a very niche use case. Panics if the Entity does not exist.

Gets a Vec of all Entities in the given World

Returns whether or not a User exists for the given RoomKey

Retrieves an UserRef that exposes read-only operations for the User associated with the given UserKey. Panics if the user does not exist.

Retrieves an UserMut that exposes read and write operations for the User associated with the given UserKey. Returns None if the user does not exist.

Return a list of all currently connected Users’ keys

Get the number of Users currently connected

Returns a UserScopeMut, which is used to include/exclude Entities for a given User

Returns whether a given User has a particular Entity in-scope currently

Creates a new Room on the Server and returns a corresponding RoomMut, which can be used to add users/entities to the room or retrieve its key

Returns whether or not a Room exists for the given RoomKey

Retrieves an RoomMut that exposes read and write operations for the Room associated with the given RoomKey. Panics if the room does not exist.

Retrieves an RoomMut that exposes read and write operations for the Room associated with the given RoomKey. Panics if the room does not exist.

Return a list of all the Server’s Rooms’ keys

Get a count of how many Rooms currently exist

Gets the last received tick from the Client

Gets the current tick of the Server

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.