aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-08 02:33:02 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-08 02:33:02 +0100
commit8fc107a31b7dd6924e7768a3c47d291047756f3f (patch)
treeaf8420a6be19bc274ff2c7db0d4ac61ddbffbc25
parent30e61e2728a086c5012ddfda453e1aa94a20b70d (diff)
downloadneetdraw-8fc107a31b7dd6924e7768a3c47d291047756f3f.tar.gz
neetdraw-8fc107a31b7dd6924e7768a3c47d291047756f3f.tar.xz
neetdraw-8fc107a31b7dd6924e7768a3c47d291047756f3f.zip
Add an option to expect all client drawing to succeed
Alias `no-wait'. So far the server always draws everything. If that stops being the case, we might want to introduce a denial response and additional logic in the client, so that it can fix its own version of the picture.
-rw-r--r--autistdraw.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/autistdraw.c b/autistdraw.c
index d3215bf..b38eade 100644
--- a/autistdraw.c
+++ b/autistdraw.c
@@ -112,6 +112,8 @@ struct app_context
struct msg_reader msg_reader; ///< Server message reader
write_queue_t write_queue; ///< Server write queue
+ bool no_wait; ///< Don't wait for server confirmations
+
// Server:
int listen_fd; ///< Listening FD
ev_io listen_watcher; ///< Listening FD watcher
@@ -514,12 +516,14 @@ draw_point_internal (app_context_t *app, int x, int y, uint8_t color)
static void
draw_point (app_context_t *app, int x, int y, uint8_t color)
{
- // We don't actually draw anything immediately in client mode,
- // instead we wait for confirmation from the server
if (app->mode == NETWORK_MODE_CLIENT)
{
send_draw_point_request (app, x, y, color);
- return;
+
+ // We don't usually draw anything immediately in client mode,
+ // instead we wait for confirmation from the server
+ if (!app->no_wait)
+ return;
}
draw_point_internal (app, x, y, color);
@@ -1372,6 +1376,7 @@ struct app_options
{
struct addrinfo *client_address; ///< Address to connect to
struct addrinfo *server_address; ///< Address to listen at
+ bool no_wait; ///< Don't wait for server confirmations
};
static void
@@ -1439,6 +1444,8 @@ parse_program_arguments (app_options_t *options, int argc, char **argv)
{ 'V', "version", NULL, 0, "output version information and exit" },
{ 's', "server", "[ADDRESS]:PORT", 0, "start a server" },
{ 'c', "client", "[ADDRESS]:PORT", 0, "connect to a server" },
+ { 'n', "no-wait", NULL, OPT_LONG_ONLY,
+ "don't wait for server confirmations" },
{ 0, NULL, NULL, 0, NULL }
};
@@ -1476,6 +1483,9 @@ parse_program_arguments (app_options_t *options, int argc, char **argv)
if (!(options->client_address = parse_address (optarg, 0)))
exit (EXIT_FAILURE);
break;
+ case 'n':
+ options->no_wait = true;
+ break;
default:
fprintf (stderr, "%s: %s\n", "error", "wrong options");
opt_handler_usage (&oh, stderr);
@@ -1617,6 +1627,7 @@ main (int argc, char *argv[])
else
app.mode = NETWORK_MODE_STANDALONE;
+ app.no_wait = options.no_wait;
app_options_free (&options);
termo_t *tk = termo_new (STDIN_FILENO, NULL, 0);