static int human;
static int raw;
static int direct;
+static int echo;
static sd_event_source *evsrc;
static char *sessionid = "afb-client-demo";
{
char *name = strrchr(arg0, '/');
name = name ? name + 1 : arg0;
- fprintf(status ? stderr : stdout, "usage: %s [-H [-r]] [-b] uri [api verb [data]]\n", name);
- fprintf(status ? stderr : stdout, " %s -d [-H [-r]] [-b] uri [verb [data]]\n", name);
+ fprintf(status ? stderr : stdout, "usage: %s [-H [-r]] [-b] [-e] uri [api verb [data]]\n", name);
+ fprintf(status ? stderr : stdout, " %s -d [-H [-r]] [-b] [-e] uri [verb [data]]\n", name);
exit(status);
}
else if (!strcmp(av[1], "--break")) /* request to break connection */
breakcon = 1;
+ else if (!strcmp(av[1], "--echo")) /* request to echo inputs */
+ echo = 1;
+
/* emit usage and exit */
else
usage(!!strcmp(av[1], "--help"), a0);
case 'r': raw = 1; break;
case 'd': direct = 1; break;
case 'b': breakcon = 1; break;
+ case 'e': echo = 1; break;
default: usage(av[1][rc] != 'h', a0);
}
}
/* allocates an id for the request */
rc = asprintf(&key, "%d:%s/%s", ++num, api, verb);
+ /* echo the command if asked */
+ if (echo)
+ printf("SEND-CALL %s/%s %s\n", api, verb, object?:"null");
+
/* send the request */
callcount++;
rc = afb_wsj1_call_s(wsj1, api, verb, object, on_wsj1_reply, key);
{
int rc;
+ /* echo the command if asked */
+ if (echo)
+ printf("SEND-EVENT: %s %s\n", event, object?:"null");
+
rc = afb_wsj1_send_event_s(wsj1, event, object);
if (rc < 0)
fprintf(stderr, "sending !%s(%s) failed: %m\n", event, object);
{
if (object == NULL || object[0] == 0)
object = "null";
+
if (api[0] == '!' && api[1] == 0)
wsj1_event(verb, object);
else
/* allocates an id for the request */
rc = asprintf(&key, "%d:%s", ++num, verb);
+ /* echo the command if asked */
+ if (echo)
+ printf("SEND-CALL: %s %s\n", verb, object?:"null");
+
/* send the request */
callcount++;
if (object == NULL || object[0] == 0 || !strcmp(object, "null"))