'What is incomingPeerID and outgoingPeerID in client and in sever in enet?
What means incomingID and outgoingID more precisely. What Id for identifying sender and what for reciever? When use one or another?
event.peer->incomingPeerID event.peer->outgoingPeerID
Client code:
ENetPeer *peer = (ENetPeer *)librg_world_userdata_get(world);
ENetHost *host = peer->host;
while (enet_host_service(host, &event, 2) > 0) {
switch (event.type) {
case ENET_EVENT_TYPE_CONNECT: {
//printf("[client] User %d has connected to the server.\n", event.peer->incomingPeerID);
//printf("[client] User %d has connected to the server.\n", event.peer->outgoingPeerID);
//!!! Don't sure what id I need to use here to detect id of connected client.
//ID = event.peer->outgoingPeerID;
} break;
case ENET_EVENT_TYPE_DISCONNECT:
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT: {
} break;
case ENET_EVENT_TYPE_RECEIVE: {
/* handle a newly received event */
librg_world_read(
world,
event.peer->outgoingPeerID, //Not sure here what ID I need to use for identifying sending client.
(char *)event.packet->data,
event.packet->dataLength,
NULL
);
/* Clean up the packet now that we're done using it. */
enet_packet_destroy(event.packet);
} break;
case ENET_EVENT_TYPE_NONE: break;
}
}
In client I need to know id's of other clients sending packets to me. It works a little strange for me. If I use event.peer->incomingPeerID I always getting zero. If I use event.peer->outgoingPeerID It seems I always getting id of reciving client itself.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
