From c88a524298aa46157638a74416e8c6e968772758 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Thu, 20 Jan 2011 18:32:39 +0100 Subject: implemented functions for notifying server of selected tablestack and for broadcasting the selection results to all clients --- src/net_client.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/net_client.c') 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 @@ -56,6 +56,24 @@ void client_selected_card(int sock, const card c) send(sock, buf, 3, 0); } +/** + * 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 @@ -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; +} + -- cgit v1.2.3