![]() |
Nazara Engine
0.4
A fast, complete, cross-platform API designed for game development
|
Network class that represents a reliable UDP connection. More...
Public Types | |
| using | SequenceIndex = UInt16 |
Public Member Functions | |
| RUdpConnection () | |
| Constructs a RUdpConnection object by default. | |
| RUdpConnection (const RUdpConnection &)=delete | |
| RUdpConnection (RUdpConnection &&)=default | |
| void | Close () |
| Closes the connection. | |
| bool | Connect (const IpAddress &remoteAddress) |
| Connects to the IpAddress. More... | |
| bool | Connect (const String &hostName, NetProtocol protocol=NetProtocol_Any, const String &service="http", ResolveError *error=nullptr) |
| Connects to the hostname. More... | |
| void | Disconnect () |
| Disconnects the connection. More... | |
| IpAddress | GetBoundAddress () const |
| Gets the bound address. More... | |
| UInt16 | GetBoundPort () const |
| Gets the port of the bound address. More... | |
| SocketError | GetLastError () const |
| Gets the last error. More... | |
| bool | Listen (NetProtocol protocol, UInt16 port=64266) |
| Listens to a socket. More... | |
| bool | Listen (const IpAddress &address) |
| Listens to a socket. More... | |
| bool | PollMessage (RUdpMessage *message) |
| Polls the message. More... | |
| bool | Send (const IpAddress &clientIp, PacketPriority priority, PacketReliability reliability, const NetPacket &packet) |
| Sends the packet to a peer. More... | |
| void | SetProtocolId (UInt32 protocolId) |
| Sets the protocol id. More... | |
| void | SetTimeBeforeAck (UInt32 ms) |
| Sets the time before ack. More... | |
| void | SimulateNetwork (double packetLoss) |
| Simulates the loss of packets on network. More... | |
| void | Update () |
| Updates the reliable connection. | |
| RUdpConnection & | operator= (const RUdpConnection &)=delete |
| RUdpConnection & | operator= (RUdpConnection &&)=default |
| NazaraSignal (OnConnectedToPeer, RUdpConnection *) | |
| NazaraSignal (OnPeerAcknowledged, RUdpConnection *, const IpAddress &) | |
| NazaraSignal (OnPeerConnection, RUdpConnection *, const IpAddress &) | |
| NazaraSignal (OnPeerDisconnected, RUdpConnection *, const IpAddress &) | |
Static Public Attributes | |
| static constexpr std::size_t | MessageHeader = sizeof(UInt16) + 2 * sizeof(SequenceIndex) + sizeof(UInt32) |
| static constexpr std::size_t | MessageFooter = sizeof(UInt16) |
Friends | |
| class | Network |
Network class that represents a reliable UDP connection.
| bool Nz::RUdpConnection::Connect | ( | const IpAddress & | remoteAddress | ) |
Connects to the IpAddress.
| remoteAddress | Address to connect to |
| bool Nz::RUdpConnection::Connect | ( | const String & | hostName, |
| NetProtocol | protocol = NetProtocol_Any, |
||
| const String & | service = "http", |
||
| ResolveError * | error = nullptr |
||
| ) |
Connects to the hostname.
| hostName | Hostname of the remote |
| protocol | Net protocol to use |
| service | Specify the protocol used |
| error | Optional argument to get the error |
|
inline |
Disconnects the connection.
|
inline |
Gets the bound address.
|
inline |
Gets the port of the bound address.
|
inline |
Gets the last error.
|
inline |
Listens to a socket.
| protocol | Net protocol to listen to |
| port | Port to listen to |
| bool Nz::RUdpConnection::Listen | ( | const IpAddress & | address | ) |
Listens to a socket.
| remoteAddress | Address to listen to |
| bool Nz::RUdpConnection::PollMessage | ( | RUdpMessage * | message | ) |
Polls the message.
| message | Message to poll |
| bool Nz::RUdpConnection::Send | ( | const IpAddress & | peerIp, |
| PacketPriority | priority, | ||
| PacketReliability | reliability, | ||
| const NetPacket & | packet | ||
| ) |
Sends the packet to a peer.
| peerIp | IpAddress of the peer |
| priority | Priority of the packet |
| reliability | Policy of reliability of the packet |
| packet | Packet to send |
Silently fail (probably a disconnected client)
|
inline |
Sets the protocol id.
| protocolId | Protocol ID like NNet |
|
inline |
Sets the time before ack.
| Time | before acking to send many together (in ms) |
|
inline |
Simulates the loss of packets on network.
| packetLoss | Ratio of packet loss according to bernoulli distribution |