diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-11-30 17:24:35 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-11-30 17:25:08 +0100 |
commit | 3e9bc6cee75c9afd8737bf5b3b20e22a720b65d7 (patch) | |
tree | d03a2c591132ccd6f18f0ca47986e385f52102cb | |
parent | 362fa366a75ec618a2389547f6d37c2a1add6624 (diff) | |
download | neetdraw-3e9bc6cee75c9afd8737bf5b3b20e22a720b65d7.tar.gz neetdraw-3e9bc6cee75c9afd8737bf5b3b20e22a720b65d7.tar.xz neetdraw-3e9bc6cee75c9afd8737bf5b3b20e22a720b65d7.zip |
Fix server-client communication
Regression was introduced by 08a2d53eb448fe80f68929111b8f6e74a44ffd50.
-rw-r--r-- | autistdraw.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/autistdraw.c b/autistdraw.c index 0a7ad62..8e85285 100644 --- a/autistdraw.c +++ b/autistdraw.c @@ -495,16 +495,8 @@ make_place_for_point (app_context_t *app, int x, int y) } static void -draw_point (app_context_t *app, int x, int y, uint8_t color) +draw_point_internal (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; - } - make_place_for_point (app, x, y); BITMAP_PIXEL (app, x - app->bitmap_x, y - app->bitmap_y) = color; @@ -517,8 +509,22 @@ draw_point (app_context_t *app, int x, int y, uint8_t color) addch (app->palette[color]); refresh (); } +} - // Broadcast the clients about the event +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; + } + + draw_point_internal (app, x, y, color); + + // Broadcast clients about the event if (app->mode == NETWORK_MODE_SERVER) for (client_t *iter = app->clients; iter; iter = iter->next) send_draw_point_response (iter, x, y, color); @@ -1119,7 +1125,9 @@ on_server_put_point (app_context_t *app, struct msg_unpacker *unpacker) || !msg_unpacker_u8 (unpacker, &color)) return false; // Not enough data - draw_point (app, x, y, color); + // Either a confirmation of our own request, or an event notification; + // let's just put the pixel in place without further ado + draw_point_internal (app, x, y, color); return true; } |