summaryrefslogtreecommitdiff
path: root/src/net_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/net_client.c')
-rw-r--r--src/net_client.c32
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;
+}
+