[][src]Struct reliudp::RUdpServer

pub struct RUdpServer { /* fields omitted */ }

A Server that holds multiple remotes

It handles incoming connections automatically, expired connections (timeouts), and obviously the ability to send/receive data and events to all remotes, either by handpicking or all at the same time.

The get_mut method allows you to get mutably a socket to send a specific remote some data. However, if you choose to not send everyone the same data, you will have to keep track of the socket addresses of the remotes in one way or another.

Methods

impl RUdpServer[src]

pub fn new<A: ToSocketAddrs>(local_addr: A) -> IoResult<RUdpServer>[src]

Tries to create a new server with the binding address.

It's often a good idea to have a value like "0.0.0.0:YOUR_PORT", to bind your address to the internet.

pub fn set_timeout_delay(&mut self, timeout_delay: u64)[src]

Set the number of iterations required before a remote is set as "dead" for all past and all new remotes.

For instance, if your tick is every 50ms, and your timeout_delay is of 24, then roughly 50*24=1200ms (=1.2s) without a message from the remote will cause a timeout error.

pub fn set_timeout_delay_with(
    &mut self,
    milliseconds: u64,
    tick_interval_milliseconds: u64
)
[src]

pub fn set_heartbeat(&mut self, delay: u64)[src]

Set the number of iterations required before we send a "heartbeat" message to the clients, so that they avoid seeing us as timeout-ed.

This delay is applied to all existing and new clients

pub fn set_heartbeat_with(
    &mut self,
    milliseconds: u64,
    tick_interval_milliseconds: u64
)
[src]

pub fn udp_socket(&self) -> Arc<UdpSocket>[src]

Returns a copy of the Arc holding the UdpSocket.

pub fn send_data(&mut self, data: &Arc<[u8]>, message_type: MessageType)[src]

Send some data to ALL remotes

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

pub fn next_tick(&mut self) -> IoResult<()>[src]

Does internal processing for all remotes. Must be done before receiving events.

pub fn iter(&self) -> impl Iterator<Item = (&SocketAddr, &RUdpSocket)>[src]

pub fn iter_mut(
    &mut self
) -> impl Iterator<Item = (&SocketAddr, &mut RUdpSocket)>
[src]

pub fn addresses(&self) -> impl Iterator<Item = &SocketAddr>[src]

pub fn get(&self, socket_addr: SocketAddr) -> Option<&RUdpSocket>[src]

Get the socket stored for given the address

pub fn get_mut(&mut self, socket_addr: SocketAddr) -> Option<&mut RUdpSocket>[src]

Get the mutable socket stored for given the address

pub fn drain_events<'a>(
    &'a mut self
) -> impl 'a + Iterator<Item = (SocketAddr, SocketEvent)>
[src]

Returns an iterator that drain events for all remotes.

Trait Implementations

impl Debug for RUdpServer[src]

impl Index<SocketAddr> for RUdpServer[src]

type Output = RUdpSocket

The returned type after indexing.

impl IndexMut<SocketAddr> for RUdpServer[src]

Auto Trait Implementations

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.