laminar/net/events.rs
1use std::net::SocketAddr;
2
3use crate::packet::Packet;
4
5/// Events that can occur in `laminar` and that will be pushed through the `event_receiver` returned by `Socket::bind`.
6#[derive(Debug, PartialEq)]
7pub enum SocketEvent {
8 /// A packet was received from a client.
9 Packet(Packet),
10 /// A new connection has been established with a client. A connection is considered
11 /// established whenever a packet has been both _sent_ and _received_ from the client.
12 ///
13 /// On the server—in order to receive a `Connect` event—you must respond to the first
14 /// Packet from a new client.
15 ///
16 /// Clients are uniquely identified by the `ip:port` combination at this layer.
17 Connect(SocketAddr),
18 /// The client has been idling for longer than the `idle_connection_timeout` time.
19 /// You can control the timeout in the config.
20 Timeout(SocketAddr),
21 /// The established connection to a client has timed out.
22 Disconnect(SocketAddr),
23}