pub struct NetworkResource {
pub connections: HashMap<ConnectionHandle, Box<dyn Connection>>,
/* private fields */
}
Fields
connections: HashMap<ConnectionHandle, Box<dyn Connection>>
Implementations
pub fn new(
task_pool: TaskPool,
link_conditioner: Option<LinkConditionerConfig>,
message_flushing_strategy: MessageFlushingStrategy,
idle_timeout_ms: Option<usize>,
auto_heartbeat_ms: Option<usize>
) -> Self
pub fn listen(
&mut self,
socket_address: SocketAddr,
webrtc_listen_address: Option<SocketAddr>,
public_webrtc_address: Option<SocketAddr>
)
pub fn listen(
&mut self,
socket_address: SocketAddr,
webrtc_listen_address: Option<SocketAddr>,
public_webrtc_address: Option<SocketAddr>
)
The 3 listening addresses aren’t strictly necessary, you can put the same IP address with a different port for the socket address; Unless you have some configuration issues with public and private addresses that need to be connected to. They also aren’t necessary if you’re using UDP, so you can put anything if that’s the case.
pub fn send(
&mut self,
handle: ConnectionHandle,
payload: Packet
) -> Result<(), Box<dyn Error + Sync + Send + 'static>>
pub fn set_channels_builder<F>(&mut self, builder: F) where
F: Fn(&mut ConnectionChannelsBuilder) + Send + Sync + 'static,
pub fn send_message<M: ChannelMessage + Debug + Clone>(
&mut self,
handle: ConnectionHandle,
message: M
) -> Result<Option<M>, Box<dyn Error + Send>>
pub fn recv_message<M: ChannelMessage + Debug + Clone>(
&mut self,
handle: ConnectionHandle
) -> Option<M>
Auto Trait Implementations
impl !RefUnwindSafe for NetworkResource
impl Send for NetworkResource
impl Sync for NetworkResource
impl Unpin for NetworkResource
impl !UnwindSafe for NetworkResource
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: 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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more