C pongd: press enter to quit.
This commit is contained in:
parent
6656e90790
commit
4d6af92a43
1 changed files with 13 additions and 2 deletions
15
c/pongd.c
15
c/pongd.c
|
|
@ -50,7 +50,14 @@ int main(int argc, char**argv) {
|
||||||
printf ("Set the timer to two seconds.\n");
|
printf ("Set the timer to two seconds.\n");
|
||||||
ipc_context_timer (ctx, 2000);
|
ipc_context_timer (ctx, 2000);
|
||||||
|
|
||||||
printf ("Loop over events.\n");
|
printf ("Listening to the standard input (press enter to quit).\n");
|
||||||
|
ret = ipc_add_external (ctx, 0);
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
return err (ctx, "Cannot listen to standard input.");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("Loop over events. Press enter to quit.\n");
|
||||||
char should_continue = 1;
|
char should_continue = 1;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
size_t count_timer = 0;
|
size_t count_timer = 0;
|
||||||
|
|
@ -68,7 +75,11 @@ int main(int argc, char**argv) {
|
||||||
|
|
||||||
switch ((enum event_types) event_type) {
|
switch ((enum event_types) event_type) {
|
||||||
case ERROR: return err(ctx, "Error.");
|
case ERROR: return err(ctx, "Error.");
|
||||||
case EXTERNAL: return err(ctx, "External (shouldn't happen).");
|
case EXTERNAL: {
|
||||||
|
printf("Quitting!\n");
|
||||||
|
should_continue = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SWITCH_RX: return err(ctx, "Switch RX (shouldn't happen).");
|
case SWITCH_RX: return err(ctx, "Switch RX (shouldn't happen).");
|
||||||
case SWITCH_TX: return err(ctx, "Switch TX (shouldn't happen).");
|
case SWITCH_TX: return err(ctx, "Switch TX (shouldn't happen).");
|
||||||
case CONNECTION: { printf ("New connection.\n"); break; }
|
case CONNECTION: { printf ("New connection.\n"); break; }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue