pub struct WebSocketServer { /* private fields */ }Expand description
Implementation of ServerSocket for WebSocket servers.
The server handles connections internally with tokio.
If the server is not connected with TLS, then connections will be encrypted using the
built-in netcode encryption implemented in renetcode2 that is used for UDP connections.
This means TLS is likely not that useful for websocket connections.
Implementations§
Source§impl WebSocketServer
impl WebSocketServer
Sourcepub fn new(config: WebSocketServerConfig, handle: Handle) -> Result<Self, Error>
pub fn new(config: WebSocketServerConfig, handle: Handle) -> Result<Self, Error>
Makes a new server.
§Errors
- Errors if unable to bind to
addr, which can happen if your machine is using all ports on a pre-defined IP address.
Trait Implementations§
Source§impl Debug for WebSocketServer
impl Debug for WebSocketServer
Source§impl Drop for WebSocketServer
impl Drop for WebSocketServer
Source§impl ServerSocket for WebSocketServer
impl ServerSocket for WebSocketServer
Source§fn is_encrypted(&self) -> bool
fn is_encrypted(&self) -> bool
Gets the encryption behavior of the socket. Read more
Source§fn is_reliable(&self) -> bool
fn is_reliable(&self) -> bool
Gets the reliability of the socket. Read more
Source§fn connection_denied(&mut self, addr: SocketAddr)
fn connection_denied(&mut self, addr: SocketAddr)
Notifies the data source that an address’s connection request was denied. Read more
Source§fn connection_accepted(&mut self, client_id: u64, addr: SocketAddr)
fn connection_accepted(&mut self, client_id: u64, addr: SocketAddr)
Notifies the data source that an address’s connection request was accepted. Read more
Source§fn disconnect(&mut self, addr: SocketAddr)
fn disconnect(&mut self, addr: SocketAddr)
Disconnects a remote connection with the given address.
Source§fn preupdate(&mut self)
fn preupdate(&mut self)
Handles data-source-specific logic that must run before receiving packets.
Source§fn try_recv(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr)>
fn try_recv(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr)>
Tries to receive the next packet sent to this data source. Read more
Source§fn postupdate(&mut self)
fn postupdate(&mut self)
Handles data-source-specific logic that must run after sending packets.
Source§fn send(
&mut self,
addr: SocketAddr,
packet: &[u8],
) -> Result<(), NetcodeTransportError>
fn send( &mut self, addr: SocketAddr, packet: &[u8], ) -> Result<(), NetcodeTransportError>
Sends a packet to the designated address. Read more
Auto Trait Implementations§
impl Freeze for WebSocketServer
impl !RefUnwindSafe for WebSocketServer
impl Send for WebSocketServer
impl Sync for WebSocketServer
impl Unpin for WebSocketServer
impl !UnwindSafe for WebSocketServer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.