|
| | Host (ENetHost *host) |
| |
| | Host (ENetHost *host, ENetPeer *serverPeer) |
| |
| uint8 | service (int timeout=0) |
| |
| bool | connectPeer (const Common::String &address, int port, int timeout=5000, int numChannels=1) |
| |
| void | disconnectPeer (int peerIndex) |
| |
| bool | send (const char *data, int peerIndex, int channel=0, bool reliable=true) |
| |
| bool | sendRawData (const Common::String &address, int port, const char *data) |
| |
| Common::String | getHost () |
| |
| int | getPort () |
| |
| int | getPeerIndexFromHost (const Common::String &host, int port) |
| |
| Common::String | getPacketData () |
| |
| void | destroyPacket () |
| |
◆ Host() [1/2]
| Networking::ENet::Host::Host |
( |
ENetHost * |
host | ) |
|
A representation of ENetHost.
- Parameters
-
| host | A pointer to ENetHost given by the createHost function. |
- See also
- Networking::ENet::createHost
◆ Host() [2/2]
A representation of ENetHost, connected to a server peer.
- Parameters
-
| host | A pointer to ENetHost given by the connnectToHost function. |
| serverPeer | a pointer to a connected peer given by the connnectToHost function. |
- See also
- Networking::ENet::connectToHost
◆ service()
| uint8 Networking::ENet::Host::service |
( |
int |
timeout = 0 | ) |
|
Services the host which receives or sends pending messages, intended to be called at the start of a game loop.
- Parameters
-
| timeout | number of milliseconds that ENet should wait for events. |
- Return values
-
| > | 0 if an event occurred within the specified time limit. |
| 0 | if no event occurred. |
| < | 0 on failure. |
◆ connectPeer()
| bool Networking::ENet::Host::connectPeer |
( |
const Common::String & |
address, |
|
|
int |
port, |
|
|
int |
timeout = 5000, |
|
|
int |
numChannels = 1 |
|
) |
| |
Connected to a foreign peer.
- Parameters
-
| address | the address of the peer that will attempt to connect to. |
| port | the port number of the peer that will attempt to connect to. |
| timeout | specifies the connection timeout in milliseconds, 5 full seconds by default. Will fail if the given time has passed. |
| numChannels | the maximum number of channels allowed; if 0, then this is equivalent to ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT. This must match with the connecting peer. |
- Return values
-
| true | on successful. |
| false | on failure. |
◆ disconnectPeer()
| void Networking::ENet::Host::disconnectPeer |
( |
int |
peerIndex | ) |
|
Disconnects a specific peer from the host.
- Parameters
-
| peerIndex | Index of a peer to disconnect. |
- Note
- A peer index can be retrieved from the getPeerIndexFromHost function.
◆ send()
| bool Networking::ENet::Host::send |
( |
const char * |
data, |
|
|
int |
peerIndex, |
|
|
int |
channel = 0, |
|
|
bool |
reliable = true |
|
) |
| |
Creates a packet and sends to a peer.
- Parameters
-
| data | Contents of the packet's data; the packet's data will remain uninitialized if data is NULL. |
| peerIndex | Index of a peer to send the packet to. |
| channel | channel on which to send; 0 by default. |
| reliable | Indicates that the packet must be received by the target peer and resend attempts will be made until the packet is delivered. |
- Return values
-
| true | on successful. |
| false | on failure. |
- Note
- Currently, if this object is created by the connectToHost function, data will always get sent to _serverPeer regardless of index given.
◆ sendRawData()
| bool Networking::ENet::Host::sendRawData |
( |
const Common::String & |
address, |
|
|
int |
port, |
|
|
const char * |
data |
|
) |
| |
Sends raw data to an address outside the ENet protocol using its UDP socket directly.
- Parameters
-
| address | Address to send data to. |
| port | Port number to send data to. |
| data | The data which will be sent. |
- Return values
-
| true | on successful. |
| false | on failure. |
- Note
- This sends data as a raw connection-less UDP socket, the same functionaility as a Networking::Socket object, but retains the address and port this host object is using.
-
Useful for hole-punching a peer, so it can connect to it.
◆ getHost()
Gets the host name of a peer that have recently connected, disconnected or received packet from.
- Returns
- String containing the host name.
- Note
- service() must be called and returned > 0 for this function to work.
◆ getPort()
| int Networking::ENet::Host::getPort |
( |
| ) |
|
Gets the port number of a peer that have recently connected, disconnected or received packet from.
- Returns
- A port number.
- Note
- service() must be called and returned > 0 for this function to work.
◆ getPeerIndexFromHost()
| int Networking::ENet::Host::getPeerIndexFromHost |
( |
const Common::String & |
host, |
|
|
int |
port |
|
) |
| |
Gets an index from a connected peer.
- Parameters
-
| host | A peer's host name |
| port | A peer's port number. |
- Return values
-
| >= | 0 containing a peer index if successfully found. |
| -1 | if not found. |
◆ getPacketData()
Gets the data from the most-recently received packet.
- Returns
- String containing the packet's data.
- Note
- service() must be called and returned ENET_EVENT_TYPE_RECEIVE (3) for this function to work.
◆ destroyPacket()
| void Networking::ENet::Host::destroyPacket |
( |
| ) |
|
Deallocate the packet, must be called upon receiving and finished using the packet's data.
The documentation for this class was generated from the following file:
- backends/networking/enet/host.h