Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Fiedler <[email protected]>
  • Loading branch information
gafferongames authored Dec 27, 2023
1 parent bf27fa9 commit 6753fca
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ if ( endpoint == NULL )
}
```
For example, in a client/server setup you would have one endpoint on each client, and n endpoints on the server. In a fully connected peer-to-peer mesh with n peers, you would have n-1 endpoints on each peer.
For example, in a client/server setup you would have one endpoint on each client, and n endpoints on the server, one for each client slot. In a fully connected peer-to-peer mesh with n peers, you would have n-1 endpoints on each peer.
You can name your endpoints for debugging by setting _name_ in the config when you create the endpoint, and use a any combination of _context_ and _id_ so you know how to send and receive packets per-endpoint. For example, a client endpoint would know to send to the server IP address, and the client n endpoint on a server would know to send packets to the address of client n via _id_.
You can name your endpoints for debugging by setting _name_ in the config, and use a any combination of _context_ and _id_ so you know how to send and receive packets per-endpoint.
Next, create a function to send packets:
For example, an endpoint beloning to a client would know to send packets to the server IP address, and a client endpoint on a server would know to send packets to the address of the specific client via _id_.
Next, create a function to transmit packets:
```c
static void transmit_packet( void * context, uint64_t id, uint16_t sequence, uint8_t * packet_data, int packet_bytes )
Expand Down Expand Up @@ -72,13 +74,13 @@ memset( packet, 0, sizeof( packet ) );
reliable_endpoint_send_packet( endpoint, packet, sizeof( packet ) );
```

And for each packet received that belongs to an endpoint, call:
And for each packet you receive from your socket, call this on the corresponding endpoint:

```c
reliable_endpoint_receive_packet( endpoint, packet_data, packet_bytes );
```
Now the process packet will be called for each packete received by the endpoint, and you can get acks for sent packets through an endpoint like this:
Now the process packet will be called for each packet received by the endpoint, and you can get acks for any packets sent through an endpoint like this:
```c
int num_acks;
Expand Down

0 comments on commit 6753fca

Please sign in to comment.