pub struct Connector<TParam: ConnectorParam> { /* private fields */ }
Expand description

The connector is used to handle handshakes and timeouts with a different, remote connector

For client-side applications, we recommend calling update_and_receive at a frequent rate

For server-side applications, we recommend dealing with your own UdpSocket receiving logic, looking up the connector based on a SocketAddr, and then calling handle_incoming_data.

The connector struct has a lot of config settings. All these settings can be found in ConnectorParam

Implementations

Create a Connector that is bound to the given remote SocketAddr

Get the socket address that this connector is paired with

Connect to the bound_addr. This will reset the internal state of the connector, and start up the connection handshake

Get the current state of this connector. This is dependent on a couple of settings in ConnectorParam:

  • If we have received a ping since ConnectorParam::RECEIVE_PING_TIMEOUT_S ago, we’re connected
  • If we have send a ping since ConnectorParam::SEND_PING_TIMEOUT_S ago, we’re connecting
  • Else we’re disconnected

Receive data from the other connector. This will call handle_incoming_data internally.

Ideally you would never need this function. Use update_and_receive on clients, and handle_incoming_data on servers.

Update this connector and receive data from the remote connector.

Update this connector. This will make sure the connection is still intact and requests any potentially missing packets.

Handles incoming data. This will perform internal logic to make sure data is being transmitted correctly, and requests missing packets.

Any actual data that was received, will be returned from this function.

Send an unconfirmed message to the other connector. It is not guaranteed that this message will ever arrive.

This is useful for data that does not have to arrive. Think of things like player movements, frames of a lossy video stream, etc.

Send a confirmed message to the other connector. The connector will try to make sure this message arrives. It is not guaranteed that messages will arrive in the same order at the other side.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.