diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-29 16:20:40 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-29 16:20:40 +0100 |
| commit | de36871c582a4f228df71e15560c020f34d39d4a (patch) | |
| tree | 07b5ee2e202b1bec7547e3b3ac8c857d7fec6540 /src/net | |
| parent | a85546a9a58ce313302f1be91923a14c5723375c (diff) | |
added more documentation
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/client.c | 47 | ||||
| -rw-r--r-- | src/net/comm.c | 15 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/net/client.c b/src/net/client.c index 409de6a..72d7322 100644 --- a/src/net/client.c +++ b/src/net/client.c @@ -59,6 +59,11 @@ int client_connect_server(const char* host, const char* port) return sock; } +/** + * Parse received list of players and fill global player list + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_player_list(const msg_t *m) { assert(m != NULL); @@ -83,6 +88,11 @@ bool client_parse_player_list(const msg_t *m) return true; } +/** + * Parse received hand and store it + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_deal_hand(const msg_t *m) { assert(m != NULL); @@ -96,6 +106,11 @@ bool client_parse_deal_hand(const msg_t *m) return true; } +/** + * Parse received index of a selected stack and store it + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_selected_stack(const msg_t *m) { assert(m != NULL); @@ -109,6 +124,11 @@ bool client_parse_selected_stack(const msg_t *m) return true; } +/** + * Parse received cards for initial stacks at beginning of game + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_initial_stacks(const msg_t *m) { assert(m != NULL); @@ -121,6 +141,11 @@ bool client_parse_initial_stacks(const msg_t *m) return true; } +/** + * Parse received open cards of all players + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_selected_card_all(const msg_t *m) { assert(m != NULL); @@ -137,6 +162,11 @@ bool client_parse_selected_card_all(const msg_t *m) return true; } +/** + * Parse received action for next round (whether new cards will be dealt ot the game is ending) + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_next_action(const msg_t *m) { assert(m != NULL); @@ -148,6 +178,11 @@ bool client_parse_next_action(const msg_t *m) return true; } +/** + * Parse received hello answer from server with assigned player id + * @param[in] m Received message + * @return Indicates success + */ bool client_parse_hello(const msg_t *m) { assert(m != NULL); @@ -159,6 +194,10 @@ bool client_parse_hello(const msg_t *m) return true; } +/** + * Prepare hello message with client's nickname + * @param[out] m Pointer to message that should be filled + */ void client_prep_hello(msg_t *m) { data_store_t *ds = data_store(); @@ -168,6 +207,10 @@ void client_prep_hello(msg_t *m) m->hdr.payload_length = namelen; } +/** + * Prepare message with selected card + * @param[out] m Pointer to message that should be filled + */ void client_prep_selected_card(msg_t *m) { data_store_t *ds = data_store(); @@ -179,6 +222,10 @@ void client_prep_selected_card(msg_t *m) m->hdr.payload_length = 1; } +/** + * Prepare message with selected stack + * @param[out] m Pointer to message that should be filled + */ void client_prep_selected_stack(msg_t *m) { data_store_t *ds = data_store(); diff --git a/src/net/comm.c b/src/net/comm.c index 7a67c27..0079a81 100644 --- a/src/net/comm.c +++ b/src/net/comm.c @@ -7,6 +7,13 @@ #include "client.h" #include "server.h" +/** + * Generic receive function.\n + * Receives specified message type from socket. Blocks until message is fully received. + * @param[in] Socket on which to receive + * @param[in] type Message type to receive + * @return Indicates success of receiving + */ bool net_recv(const int sock, const msg_type_t type) { msg_t m; @@ -70,6 +77,14 @@ bool net_recv(const int sock, const msg_type_t type) return result; } +/** + * Generic send function.\n + * Transmits specified message type on socket. + * @param[in] Socket on which to send + * @param[in] type Message type to send + * @param[in] data Optional pointer to extra data needed by some message types + * @return Indicates success of sending + */ bool net_send(const int sock, const msg_type_t type, const void *data) { bool result = true; |
