diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-20 18:32:39 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-20 18:32:39 +0100 |
| commit | c88a524298aa46157638a74416e8c6e968772758 (patch) | |
| tree | fd199a53a8a58bbb89d89490dc7cacb6cbd38797 /src/net_server.c | |
| parent | 246e1678c54bedc7d0d0276654e5205647ff5360 (diff) | |
implemented functions for notifying server of selected tablestack and for broadcasting the selection results to all clients
Diffstat (limited to 'src/net_server.c')
| -rw-r--r-- | src/net_server.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/net_server.c b/src/net_server.c index 0cba08c..731e232 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -159,6 +159,26 @@ void server_start_game(int* clients, const uint8_t clientcount, const player_lis } /** + * Server side function; broadcast a selected table stack to all clients + * @param[in] clients Array of sockets with connections to clients + * @param[in] clientcount Number of sockets/clients + * @param[in] stackindex Selected stack to broadcast + */ +void server_send_selected_stack(int* clients, const uint8_t clientcount, const uint8_t stackindex) +{ + assert(clients != NULL); + assert(stackindex <= NUM_TABLE_STACKS); + + uint8_t buf[3]; + buf[NET_MSG_OFFSET_TYPE] = msg_type_selected_stack_s; + buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] = 1; + buf[NET_MSG_OFFSET_PAYLOAD] = stackindex; + + for(int i=0; i<clientcount; i++) + send(clients[i], buf, 3, 0); +} + +/** * Server side function; receive hello message from client and read username * @param[in] sock Socket to use * @return Username of client @@ -193,6 +213,17 @@ card* server_recv_selected_card(const uint8_t* payload, const uint8_t payload_le return c; } +uint8_t* server_recv_selected_stack(const uint8_t* payload, const uint8_t payload_len) +{ + assert(payload != NULL && payload_len == 1); + + uint8_t* index = malloc(sizeof(uint8_t)); + assert(index != NULL); + *index = payload[0]; + + return index; +} + /** * Server side function; deal cards to a client (send hand) * @param[in] sock Socket to use |
