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_client.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_client.c')
| -rw-r--r-- | src/net_client.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/net_client.c b/src/net_client.c index b51c7a0..9454649 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -57,6 +57,24 @@ void client_selected_card(int sock, const card c) } /** + * Client side function; Send selected table stack to server + * @param[in] sock Socket to use + * @param[in] stackindex Index of selected stack + */ +void client_send_selected_stack(int sock, const uint8_t stackindex) +{ + assert(stackindex <= NUM_TABLE_STACKS); + + uint8_t buf[3]; + + buf[NET_MSG_OFFSET_TYPE] = msg_type_selected_stack_c; + buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] = 1; + buf[NET_MSG_OFFSET_PAYLOAD] = stackindex; + + send(sock, buf, 3, 0); +} + +/** * Client side function; connects to specified host:port * @param[in] host Hostname of server * @param[in] port Port of server @@ -151,3 +169,17 @@ hand_t *client_recv_deal_cards(const uint8_t* payload, const uint8_t payload_len return h; } + +uint8_t* client_recv_selected_stack(const uint8_t* payload, const uint8_t payload_len) +{ + assert(payload != NULL); + assert(payload_len == 1); + + uint8_t* stackindex = malloc(sizeof(uint8_t)); + *stackindex = payload[0]; + + assert(*stackindex <= NUM_TABLE_STACKS); + + return stackindex; +} + |
