[][src]Struct grubbnet::Server

pub struct Server { /* fields omitted */ }

Methods

impl Server[src]

pub fn host(ip: &str, port: u16, connection_limit: usize) -> Result<Server>[src]

Begin hosting a TCP server.

pub fn num_connections(&self) -> usize[src]

Get the current number of connections.

pub fn connection_limit(&self) -> usize[src]

Get the maximum number of connections allowed.

pub fn drain_incoming_packets(&mut self) -> Vec<(Token, Packet)>[src]

Drain any incoming packets and return them.

pub fn kick(&mut self, connection_token: Token) -> Result<()>[src]

Kick a connection from the server.

pub fn send(&mut self, recipient: PacketRecipient, packet: impl PacketBody)[src]

Send a packet. This function will box the packet, then queue it to be sent on the next server tick.

pub fn send_boxed(
    &mut self,
    recipient: PacketRecipient,
    packet_boxed: Box<dyn PacketBody>
)
[src]

Send a boxed packet. Similar to send, but this is moreuseful when you have a boxed packet already and don't want to cast it to a concrete type before sending it.

pub fn tick(&mut self) -> Vec<ServerEvent>[src]

Runs a network tick, which sends/receives packets based on socket readiness, as well as accepts new connections.

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: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.