From f0f93f4d790343c4ae51ca55f165886c01358c89 Mon Sep 17 00:00:00 2001 From: jobol Date: Thu, 26 May 2016 18:12:54 +0200 Subject: rename parameter to argument Signed-off-by: jobol --- plugins/samples/tic-tac-toe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/samples/tic-tac-toe.c b/plugins/samples/tic-tac-toe.c index a1630c50..67cddcb6 100644 --- a/plugins/samples/tic-tac-toe.c +++ b/plugins/samples/tic-tac-toe.c @@ -364,11 +364,11 @@ static void move(struct afb_req req) board = board_of_req(req); INFO(afbitf, "method 'move' called for boardid %d", board->id); - /* retrieves the parameters of the move */ + /* retrieves the arguments of the move */ index = afb_req_value(req, "index"); i = index == NULL ? -1 : atoi(index); - /* checks validity of parameters */ + /* checks validity of arguments */ if (i < 0 || i > 8) { WARNING(afbitf, "can't move to %s: %s", index?:"?", index?"wrong value":"not set"); afb_req_fail(req, "error", "bad request"); @@ -413,11 +413,11 @@ static void level(struct afb_req req) board = board_of_req(req); INFO(afbitf, "method 'level' called for boardid %d", board->id); - /* retrieves the parameters */ + /* retrieves the arguments */ level = afb_req_value(req, "level"); l = level == NULL ? -1 : atoi(level); - /* check validity of parameters */ + /* check validity of arguments */ if (l < 1 || l > 10) { WARNING(afbitf, "can't set level to %s: %s", level?:"?", level?"wrong value":"not set"); afb_req_fail(req, "error", "bad request"); @@ -447,7 +447,7 @@ static void join(struct afb_req req) board = board_of_req(req); INFO(afbitf, "method 'join' called for boardid %d", board->id); - /* retrieves the parameters */ + /* retrieves the arguments */ id = afb_req_value(req, "boardid"); if (id == NULL) goto bad_request; -- cgit From ed6b81ea46629ae69176e77aec14844257dc36af Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Fri, 27 May 2016 11:04:56 +0200 Subject: Improve Audio plugin PulseAudio backend Remove obvious errors from the PulseAudio backend. It does not work yet (permissions issues ?), and some parts of the code are still hardly self-explaining. Signed-off-by: Manuel Bachmann --- plugins/audio/audio-pulse.c | 64 +++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 26 deletions(-) (limited to 'plugins') diff --git a/plugins/audio/audio-pulse.c b/plugins/audio/audio-pulse.c index 7f511be1..50ddf40c 100644 --- a/plugins/audio/audio-pulse.c +++ b/plugins/audio/audio-pulse.c @@ -65,10 +65,10 @@ unsigned char _pulse_init (const char *name, audioCtxHandleT *ctx) { fprintf (stderr, "Stopping PulseAudio backend...\n"); return 0; } - if (ret >= 0) { + if (ret > 0) { /* found a matching sink from callback */ - fprintf (stderr, "Success : using sink n.%d\n", error); - ctx->audio_dev = (void*)dev_ctx_p[ret]; + fprintf (stderr, "Success : using sink n.%d\n", ret-1); + ctx->audio_dev = (void*)dev_ctx_p[ret-1]; break; } gettimeofday (&tv_now, NULL); @@ -78,11 +78,11 @@ unsigned char _pulse_init (const char *name, audioCtxHandleT *ctx) { return 0; /* make the client context aware of current card state */ - ctx->mute = (unsigned char)dev_ctx_p[ret]->mute; - ctx->channels = (unsigned int)dev_ctx_p[ret]->volume.channels; + ctx->mute = (unsigned char)dev_ctx_p[ret-1]->mute; + ctx->channels = (unsigned int)dev_ctx_p[ret-1]->volume.channels; for (i = 0; i < ctx->channels; i++) - ctx->volume[i] = dev_ctx_p[ret]->volume.values[i]; - ctx->idx = ret; + ctx->volume[i] = dev_ctx_p[ret-1]->volume.values[i]; + ctx->idx = ret-1; /* open matching sink for playback */ pa_spec = (pa_sample_spec*) malloc (sizeof(pa_sample_spec)); @@ -90,13 +90,13 @@ unsigned char _pulse_init (const char *name, audioCtxHandleT *ctx) { pa_spec->rate = 22050; pa_spec->channels = (uint8_t)ctx->channels; - if (!(pa = pa_simple_new (NULL, "afb-audio-plugin", PA_STREAM_PLAYBACK, dev_ctx_p[ret]->sink_name, + if (!(pa = pa_simple_new (NULL, "afb-audio-plugin", PA_STREAM_PLAYBACK, dev_ctx_p[ret-1]->sink_name, "afb-audio-output", pa_spec, NULL, NULL, &error))) { fprintf (stderr, "Error opening PulseAudio sink %s : %s\n", - dev_ctx_p[ret]->sink_name, pa_strerror(error)); + dev_ctx_p[ret-1]->sink_name, pa_strerror(error)); return 0; } - dev_ctx_p[ret]->pa = pa; + dev_ctx_p[ret-1]->pa = pa; free (pa_spec); client_count++; @@ -113,7 +113,7 @@ void _pulse_free (audioCtxHandleT *ctx) { client_count--; if (client_count > 0) return; - for (num = 0; num < (sizeof(dev_ctx_p)/sizeof(dev_ctx_pulse_T)); num++) { + for (num = 0; num < (sizeof(dev_ctx_p)/sizeof(dev_ctx_pulse_T*)); num++) { for (i = 0; num < (sizeof(dev_ctx_p[num]->card_name)/sizeof(char*)); i++) { free (dev_ctx_p[num]->card_name[i]); @@ -245,7 +245,7 @@ void _pulse_enumerate_cards () { int new_info, i, num = 0; /* allocate the global alsa array */ - alsa_info = (alsa_info_T**) malloc (sizeof(alsa_info_T)); + alsa_info = (alsa_info_T**) malloc (sizeof(alsa_info_T*)); alsa_info[0] = (alsa_info_T*) malloc (sizeof(alsa_info_T)); alsa_info[0]->device = NULL; alsa_info[0]->synonyms = NULL; @@ -276,7 +276,7 @@ void _pulse_enumerate_cards () { if (found) card_name[found-card_name] = '\0'; /* was the card name already listed in the global alsa array ? */ - for (i = 0; i < (sizeof(alsa_info)/sizeof(alsa_info_T)); i++) { + for (i = 0; i < (sizeof(alsa_info)/sizeof(alsa_info_T*)); i++) { if (alsa_info[i]->device && !strcmp (alsa_info[i]->device, card_name)) { @@ -288,7 +288,7 @@ void _pulse_enumerate_cards () { } /* it was not ; create it */ if (new_info) { - alsa_info = (alsa_info_T**) realloc (alsa_info, (num+1)*sizeof(alsa_info_T)); + alsa_info = (alsa_info_T**) realloc (alsa_info, (num+1)*sizeof(alsa_info_T*)); alsa_info[num]->device = strdup (card_name); asprintf (&alsa_info[num]->synonyms, ":%s", alsa_name); num++; @@ -309,12 +309,12 @@ char** _pulse_find_cards (const char *name) { asprintf (&needle, ":%s", name); - for (num = 0; num < (sizeof(alsa_info)/sizeof(alsa_info_T)); num++) { + for (num = 0; num < (sizeof(alsa_info)/sizeof(alsa_info_T*)); num++) { found = strstr (alsa_info[num]->synonyms, needle); while (found) { /* if next character is not ':' or '\0', we are wrong */ - if ((found[strlen(name)] != ':') && (found[strlen(name)] != '\0')) { + if ((found[strlen(name)+1] != ':') && (found[strlen(name)+1] != '\0')) { found = strstr (found+1, needle); continue; } @@ -322,11 +322,12 @@ char** _pulse_find_cards (const char *name) { found = strstr (alsa_info[num]->synonyms, ":"); while (found) { next = strstr (found+1, ":"); + if (!next) break; cards = (char**) realloc (cards, (i+1)*sizeof(char*)); cards[i] = (char*) malloc (next-found+1); strncpy (cards[i], found+1, next-found); - cards[i][next-found] = '\0'; - i++; + cards[i][next-found-1] = '\0'; + found = next; i++; } } } @@ -356,20 +357,20 @@ void _pulse_sink_list_cb (pa_context *context, const pa_sink_info *info, dev_ctx_pulse_T *dev_ctx_p_t = (dev_ctx_pulse_T *)data; const char *device_string; + char *device, *found; char **cards; int num, i; if (eol != 0) return; + device_string = pa_proplist_gets (info->proplist, "device.string"); /* ignore sinks with no cards */ - if (!pa_proplist_contains (info->proplist, "device.string")) + if (!device_string) return; - device_string = pa_proplist_gets (info->proplist, "device.string"); - /* was a sink with similar name already found ? */ - for (num = 0; num < (sizeof(dev_ctx_p)/sizeof(dev_ctx_pulse_T)); num++) { + for (num = 0; num < (sizeof(dev_ctx_p)/sizeof(dev_ctx_pulse_T*)); num++) { if (dev_ctx_p[num]->sink_name && !strcmp (dev_ctx_p[num]->sink_name, info->name)) { @@ -379,7 +380,8 @@ void _pulse_sink_list_cb (pa_context *context, const pa_sink_info *info, if (!strcmp (cards[i], dev_ctx_p_t->card_name[0])) { /* it did : stop there and succeed */ fprintf (stderr, "Found matching sink : %s\n", info->name); - pa_mainloop_quit (dev_ctx_p_t->pa_loop, num); + /* we return num+1 because '0' is already used */ + pa_mainloop_quit (dev_ctx_p_t->pa_loop, num+1); } } /* it did not, ignore and return */ @@ -388,11 +390,20 @@ void _pulse_sink_list_cb (pa_context *context, const pa_sink_info *info, } num++; + /* remove ending ":0",":1"... in device name */ + device = strdup (device_string); + found = strstr (device, ":"); + if (found) device[found-device] = '\0'; + +fprintf(stderr, "BEFORE PULSE_FIND_CARDS\n"); /* new sink, find all the cards it manages, fail if none */ - cards = _pulse_find_cards (device_string); - if (!cards) return; + cards = _pulse_find_cards (device); + free (device); + if (!cards) + return; /* everything is well, register it in global array */ +fprintf(stderr, "NEW SINK IN GLOBAL ARRAY\n"); dev_ctx_p_t->sink_name = strdup (info->name); dev_ctx_p_t->card_name = cards; dev_ctx_p_t->mute = info->mute; @@ -406,7 +417,8 @@ void _pulse_sink_list_cb (pa_context *context, const pa_sink_info *info, if (!strcmp (cards[i], dev_ctx_p_t->card_name[0])) { /* it did : stop there and succeed */ fprintf (stderr, "Found matching sink : %s\n", info->name); - pa_mainloop_quit (dev_ctx_p_t->pa_loop, num); + /* we return num+1 because '0' is already used */ + pa_mainloop_quit (dev_ctx_p_t->pa_loop, num+1); } } } -- cgit From a1ed2c12ac2a305a54f35a3dad99b85cbe3113e6 Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Fri, 27 May 2016 14:16:54 +0200 Subject: Improve Audio plugin PulseAudio backend >100 return values are strangely returned by PulseAudio when doing an initial connection from afb-daemon. Just ignore them, because it breaks the logic. Allow 2 seconds of initial asynchronous connection (it should return earlier anyways). Signed-off-by: Manuel Bachmann --- plugins/audio/audio-pulse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/audio/audio-pulse.c b/plugins/audio/audio-pulse.c index 50ddf40c..739b3774 100644 --- a/plugins/audio/audio-pulse.c +++ b/plugins/audio/audio-pulse.c @@ -58,14 +58,16 @@ unsigned char _pulse_init (const char *name, audioCtxHandleT *ctx) { /* 1 second should be sufficient to retrieve sink info */ gettimeofday (&tv_start, NULL); gettimeofday (&tv_now, NULL); - while (tv_now.tv_sec - tv_start.tv_sec <= 1) { + while (tv_now.tv_sec - tv_start.tv_sec <= 2) { pa_mainloop_iterate (pa_loop, 0, &ret); if (ret == -1) { fprintf (stderr, "Stopping PulseAudio backend...\n"); return 0; } - if (ret > 0) { + + /* 0 and >100 are returned by PulseAudio itself */ + if ((ret > 0)&&(ret < 100)) { /* found a matching sink from callback */ fprintf (stderr, "Success : using sink n.%d\n", ret-1); ctx->audio_dev = (void*)dev_ctx_p[ret-1]; @@ -395,7 +397,6 @@ void _pulse_sink_list_cb (pa_context *context, const pa_sink_info *info, found = strstr (device, ":"); if (found) device[found-device] = '\0'; -fprintf(stderr, "BEFORE PULSE_FIND_CARDS\n"); /* new sink, find all the cards it manages, fail if none */ cards = _pulse_find_cards (device); free (device); @@ -403,7 +404,6 @@ fprintf(stderr, "BEFORE PULSE_FIND_CARDS\n"); return; /* everything is well, register it in global array */ -fprintf(stderr, "NEW SINK IN GLOBAL ARRAY\n"); dev_ctx_p_t->sink_name = strdup (info->name); dev_ctx_p_t->card_name = cards; dev_ctx_p_t->mute = info->mute; -- cgit From 146bb49ca5acf4bbd5d9841398030c29b4333cc6 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 27 May 2016 14:57:29 +0200 Subject: improves naming MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If26d8b9af05c84bd24d0ac3ceb9a628a0039c2a6 Signed-off-by: José Bollo --- plugins/samples/tic-tac-toe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/samples/tic-tac-toe.c b/plugins/samples/tic-tac-toe.c index 67cddcb6..4bae8d75 100644 --- a/plugins/samples/tic-tac-toe.c +++ b/plugins/samples/tic-tac-toe.c @@ -583,7 +583,7 @@ static void wait(struct afb_req req) /* * array of the verbs exported to afb-daemon */ -static const struct AFB_verb_desc_v1 verbs[] = { +static const struct AFB_verb_desc_v1 plugin_verbs[] = { /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL SHORT DESCRIPTION */ { .name= "new", .session= AFB_SESSION_NONE, .callback= new, .info= "Starts a new game" }, { .name= "play", .session= AFB_SESSION_NONE, .callback= play, .info= "Tells the server to play" }, @@ -593,8 +593,7 @@ static const struct AFB_verb_desc_v1 verbs[] = { { .name= "join", .session= AFB_SESSION_CHECK,.callback= join, .info= "Join a board" }, { .name= "undo", .session= AFB_SESSION_NONE, .callback= undo, .info= "Undo the last move" }, { .name= "wait", .session= AFB_SESSION_NONE, .callback= wait, .info= "Wait for a change" }, - /* marker for end of the array */ - { .name= NULL } + { .name= NULL } /* marker for end of the array */ }; /* @@ -607,7 +606,7 @@ static const struct AFB_plugin plugin_description = .v1= { /* fills the v1 field of the union when AFB_PLUGIN_VERSION_1 */ .prefix= "tictactoe", /* the API name (or plugin name or prefix) */ .info= "Sample tac-tac-toe game", /* short description of of the plugin */ - .verbs = verbs /* the array describing the verbs of the API */ + .verbs = plugin_verbs /* the array describing the verbs of the API */ } }; -- cgit From 69b098942bd6c5b54d4849564407f9d20e598c06 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 27 May 2016 15:25:46 +0200 Subject: fix formatting error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1e5842a43a50c357d78f3318b4c0eed8ad1676e2 Signed-off-by: José Bollo --- plugins/samples/tic-tac-toe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/samples/tic-tac-toe.c b/plugins/samples/tic-tac-toe.c index 4bae8d75..79aaaf58 100644 --- a/plugins/samples/tic-tac-toe.c +++ b/plugins/samples/tic-tac-toe.c @@ -390,7 +390,7 @@ static void move(struct afb_req req) } /* applies the move */ - INFO(afbitf, "method 'move' for boardid %d, index=%d", board->id, index); + INFO(afbitf, "method 'move' for boardid %d, index=%s", board->id, index); add_move(board, i); /* replies */ -- cgit From 18439204034fca982b3b65c2d581f80a9ee62f56 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 27 May 2016 16:41:59 +0200 Subject: terminology: Level Of Assurance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3c92aab34ba9414faf19d9a96d8f1de786f1e7b6 Signed-off-by: José Bollo --- plugins/samples/ClientCtx.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'plugins') diff --git a/plugins/samples/ClientCtx.c b/plugins/samples/ClientCtx.c index 353185c3..ef703759 100644 --- a/plugins/samples/ClientCtx.c +++ b/plugins/samples/ClientCtx.c @@ -125,22 +125,22 @@ static const struct AFB_verb_desc_v1 verbs[]= { {"create", AFB_SESSION_CREATE, myCreate , "Create a new session"}, {"action", AFB_SESSION_CHECK , myAction , "Use Session Context"}, {"close" , AFB_SESSION_CLOSE , myClose , "Free Context"}, - {"set_loa_0", AFB_SESSION_RENEW, clientSetLOA0 ,"Set level of authorisation to 0"}, - {"set_loa_1", AFB_SESSION_RENEW, clientSetLOA1 ,"Set level of authorisation to 1"}, - {"set_loa_2", AFB_SESSION_RENEW, clientSetLOA2 ,"Set level of authorisation to 2"}, - {"set_loa_3", AFB_SESSION_RENEW, clientSetLOA3 ,"Set level of authorisation to 3"}, - {"check_loa_ge_0", AFB_SESSION_LOA_GE_0, clientCheckLOA ,"Check whether level of authorisation is greater or equal to 0"}, - {"check_loa_ge_1", AFB_SESSION_LOA_GE_1, clientCheckLOA ,"Check whether level of authorisation is greater or equal to 1"}, - {"check_loa_ge_2", AFB_SESSION_LOA_GE_2, clientCheckLOA ,"Check whether level of authorisation is greater or equal to 2"}, - {"check_loa_ge_3", AFB_SESSION_LOA_GE_3, clientCheckLOA ,"Check whether level of authorisation is greater or equal to 3"}, - {"check_loa_le_0", AFB_SESSION_LOA_LE_0, clientCheckLOA ,"Check whether level of authorisation is lesser or equal to 0"}, - {"check_loa_le_1", AFB_SESSION_LOA_LE_1, clientCheckLOA ,"Check whether level of authorisation is lesser or equal to 1"}, - {"check_loa_le_2", AFB_SESSION_LOA_LE_2, clientCheckLOA ,"Check whether level of authorisation is lesser or equal to 2"}, - {"check_loa_le_3", AFB_SESSION_LOA_LE_3, clientCheckLOA ,"Check whether level of authorisation is lesser or equal to 3"}, - {"check_loa_eq_0", AFB_SESSION_LOA_EQ_0, clientCheckLOA ,"Check whether level of authorisation is equal to 0"}, - {"check_loa_eq_1", AFB_SESSION_LOA_EQ_1, clientCheckLOA ,"Check whether level of authorisation is equal to 1"}, - {"check_loa_eq_2", AFB_SESSION_LOA_EQ_2, clientCheckLOA ,"Check whether level of authorisation is equal to 2"}, - {"check_loa_eq_3", AFB_SESSION_LOA_EQ_3, clientCheckLOA ,"Check whether level of authorisation is equal to 3"}, + {"set_loa_0", AFB_SESSION_RENEW, clientSetLOA0 ,"Set level of assurance to 0"}, + {"set_loa_1", AFB_SESSION_RENEW, clientSetLOA1 ,"Set level of assurance to 1"}, + {"set_loa_2", AFB_SESSION_RENEW, clientSetLOA2 ,"Set level of assurance to 2"}, + {"set_loa_3", AFB_SESSION_RENEW, clientSetLOA3 ,"Set level of assurance to 3"}, + {"check_loa_ge_0", AFB_SESSION_LOA_GE_0, clientCheckLOA ,"Check whether level of assurance is greater or equal to 0"}, + {"check_loa_ge_1", AFB_SESSION_LOA_GE_1, clientCheckLOA ,"Check whether level of assurance is greater or equal to 1"}, + {"check_loa_ge_2", AFB_SESSION_LOA_GE_2, clientCheckLOA ,"Check whether level of assurance is greater or equal to 2"}, + {"check_loa_ge_3", AFB_SESSION_LOA_GE_3, clientCheckLOA ,"Check whether level of assurance is greater or equal to 3"}, + {"check_loa_le_0", AFB_SESSION_LOA_LE_0, clientCheckLOA ,"Check whether level of assurance is lesser or equal to 0"}, + {"check_loa_le_1", AFB_SESSION_LOA_LE_1, clientCheckLOA ,"Check whether level of assurance is lesser or equal to 1"}, + {"check_loa_le_2", AFB_SESSION_LOA_LE_2, clientCheckLOA ,"Check whether level of assurance is lesser or equal to 2"}, + {"check_loa_le_3", AFB_SESSION_LOA_LE_3, clientCheckLOA ,"Check whether level of assurance is lesser or equal to 3"}, + {"check_loa_eq_0", AFB_SESSION_LOA_EQ_0, clientCheckLOA ,"Check whether level of assurance is equal to 0"}, + {"check_loa_eq_1", AFB_SESSION_LOA_EQ_1, clientCheckLOA ,"Check whether level of assurance is equal to 1"}, + {"check_loa_eq_2", AFB_SESSION_LOA_EQ_2, clientCheckLOA ,"Check whether level of assurance is equal to 2"}, + {"check_loa_eq_3", AFB_SESSION_LOA_EQ_3, clientCheckLOA ,"Check whether level of assurance is equal to 3"}, {NULL} }; -- cgit From d96d0533b8326570db57d13b8f808bc62d1a7fa4 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 27 May 2016 22:18:26 +0200 Subject: improves documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idbd1b735571c2e35daed23d43f8d5d3990881533 Signed-off-by: José Bollo --- plugins/samples/HelloWorld.c | 4 ++-- plugins/samples/tic-tac-toe.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/samples/HelloWorld.c b/plugins/samples/HelloWorld.c index 78a1eafd..fe117846 100644 --- a/plugins/samples/HelloWorld.c +++ b/plugins/samples/HelloWorld.c @@ -54,8 +54,8 @@ static void pingBug (struct afb_req request) static void pingEvent(struct afb_req request) { json_object *query = afb_req_json(request); - afb_event_sender_push(afb_daemon_get_event_sender(interface->daemon), "event", query); - ping(request, json_object_get(query), "event"); + afb_daemon_broadcast_event(interface->daemon, "event", json_object_get(query)); + ping(request, query, "event"); } diff --git a/plugins/samples/tic-tac-toe.c b/plugins/samples/tic-tac-toe.c index 79aaaf58..c372e99f 100644 --- a/plugins/samples/tic-tac-toe.c +++ b/plugins/samples/tic-tac-toe.c @@ -299,7 +299,7 @@ static void changed(struct board *board, const char *reason) waiter = next; } - afb_event_sender_push(afb_daemon_get_event_sender(afbitf->daemon), reason, description); + afb_daemon_broadcast_event(afbitf->daemon, reason, description); } /* @@ -586,7 +586,7 @@ static void wait(struct afb_req req) static const struct AFB_verb_desc_v1 plugin_verbs[] = { /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL SHORT DESCRIPTION */ { .name= "new", .session= AFB_SESSION_NONE, .callback= new, .info= "Starts a new game" }, - { .name= "play", .session= AFB_SESSION_NONE, .callback= play, .info= "Tells the server to play" }, + { .name= "play", .session= AFB_SESSION_NONE, .callback= play, .info= "Asks the server to play" }, { .name= "move", .session= AFB_SESSION_NONE, .callback= move, .info= "Tells the client move" }, { .name= "board", .session= AFB_SESSION_NONE, .callback= board, .info= "Get the current board" }, { .name= "level", .session= AFB_SESSION_NONE, .callback= level, .info= "Set the server level" }, -- cgit From 13b6d9bb553e996f76bc5f9bb1d9f7094e0e104b Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 27 May 2016 23:07:19 +0200 Subject: removes restriction on the count of waiters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in fact, using more than on web socket, the same client (same session) can lock itself using wait and unlock itself using move... Change-Id: I4ebd8fa93d3373589e9bb7fac7c250e29f94c460 Signed-off-by: José Bollo --- plugins/samples/tic-tac-toe.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'plugins') diff --git a/plugins/samples/tic-tac-toe.c b/plugins/samples/tic-tac-toe.c index c372e99f..31682d94 100644 --- a/plugins/samples/tic-tac-toe.c +++ b/plugins/samples/tic-tac-toe.c @@ -549,7 +549,6 @@ static void play(struct afb_req req) static void wait(struct afb_req req) { - int count; struct board *board; struct waiter *waiter; @@ -557,21 +556,6 @@ static void wait(struct afb_req req) board = board_of_req(req); INFO(afbitf, "method 'wait' called for boardid %d", board->id); - /* counts the waiters */ - count = 0; - waiter = board->waiters; - while (waiter != NULL) { - count++; - waiter = waiter->next; - } - - /* checks ability to wait */ - if (count + 1 >= board->use_count) { - WARNING(afbitf, "can't wait: count=%d and use_count=%d", count, board->use_count); - afb_req_fail(req, "error", "can't wait"); - return; - } - /* creates the waiter and enqueues it */ waiter = calloc(1, sizeof *waiter); waiter->req = req; -- cgit